From 6bae6d910bf9a0746a3ceb39a7045d56821f7a4f Mon Sep 17 00:00:00 2001
From: John Vandenberg <jayvdb@gmail.com>
Date: Wed, 8 Nov 2017 11:31:25 +0700
Subject: [PATCH 001/105] 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 <jayvdb@gmail.com>
Date: Wed, 8 Nov 2017 11:22:33 +0700
Subject: [PATCH 002/105] 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 <willkg@users.noreply.github.com>
Date: Tue, 21 Nov 2017 11:08:51 -0500
Subject: [PATCH 003/105] 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 <hugovk@users.noreply.github.com>
Date: Wed, 22 Nov 2017 16:30:52 +0200
Subject: [PATCH 004/105] 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 <jayvdb@gmail.com>
Date: Thu, 23 Nov 2017 22:51:09 +0700
Subject: [PATCH 005/105] .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 <jayvdb@gmail.com>
Date: Fri, 24 Nov 2017 19:02:25 +0700
Subject: [PATCH 006/105] 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 <willkg@users.noreply.github.com>
Date: Tue, 28 Nov 2017 17:30:48 -0500
Subject: [PATCH 007/105] 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 <jayvdb@gmail.com>
Date: Thu, 23 Nov 2017 22:22:48 +0700
Subject: [PATCH 008/105] 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 <jayvdb@gmail.com>
Date: Thu, 23 Nov 2017 11:59:03 +0700
Subject: [PATCH 009/105] 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 <willkg@mozilla.com>
Date: Tue, 28 Nov 2017 19:20:46 -0500
Subject: [PATCH 010/105] 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 <willkg@users.noreply.github.com>
Date: Wed, 29 Nov 2017 07:00:26 -0500
Subject: [PATCH 011/105] 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 <willkg@mozilla.com>
Date: Wed, 29 Nov 2017 09:50:54 -0500
Subject: [PATCH 012/105] 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 <hugovk@users.noreply.github.com>
Date: Thu, 30 Nov 2017 17:53:44 +0200
Subject: [PATCH 013/105] 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 <hugovk@users.noreply.github.com>
Date: Thu, 30 Nov 2017 18:00:54 +0200
Subject: [PATCH 014/105] 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,
                "<img src=\"%s:%s\">foo</a>" % (protocol, rest_of_uri),
                """<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
+
+
+def test_lowercase_color_codes_in_style():
+    sanitized = sanitize_html("<p style=\"border: 1px solid #a2a2a2;\"></p>")
+    expected = '<p style=\"border: 1px solid #a2a2a2;\"></p>'
+    assert expected == sanitized
+
+
+def test_uppercase_color_codes_in_style():
+    sanitized = sanitize_html("<p style=\"border: 1px solid #A2A2A2;\"></p>")
+    expected = '<p style=\"border: 1px solid #A2A2A2;\"></p>'
+    assert expected == sanitized

From a5a19007cdd951396bd769f1bac937de99b10f30 Mon Sep 17 00:00:00 2001
From: Hugo <hugovk@users.noreply.github.com>
Date: Thu, 30 Nov 2017 18:02:01 +0200
Subject: [PATCH 015/105] 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 <hugovk@users.noreply.github.com>
Date: Thu, 30 Nov 2017 18:23:54 +0200
Subject: [PATCH 016/105] 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 <mvasilkov@gmail.com>
Date: Thu, 30 Nov 2017 20:22:58 +0300
Subject: [PATCH 017/105] 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 <willkg@users.noreply.github.com>
Date: Thu, 30 Nov 2017 18:00:23 -0500
Subject: [PATCH 018/105] 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 = '<html><body>Hi!</body></html>'
+   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 <willkg@users.noreply.github.com>
Date: Thu, 30 Nov 2017 18:02:28 -0500
Subject: [PATCH 019/105] 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 <willkg@users.noreply.github.com>
Date: Thu, 30 Nov 2017 18:08:08 -0500
Subject: [PATCH 020/105] 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('<html><body><p>Hi!</p></body></html>')
+    >>> serialize(token_stream, omit_optional_tags=False)
+    '<html><head></head><body><p>Hi!</p></body></html>'
+
+    """
     # 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 &lt; &gt; &amp; &quot; &apos;
-          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 <input disabled="disabled"> becomes <input disabled>.
-        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. <hr/>.
-        space_before_trailing_solidus=True|False
-          Places a space immediately before the closing slash in a tag
-          using a trailing solidus. E.g. <hr />. 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 &lt; &gt;
+            &amp; &quot; &apos; 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::
+
+              <input disabled="disabled">
+
+            becomes::
+
+              <input disabled>
+
+            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. ``<hr/>``.
+
+            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.
+            ``<hr />``. 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('<html><body>Hi!</body></html>')
+        >>> walker = getTreeWalker('etree')
+        >>> serializer = HTMLSerializer(omit_optional_tags=False)
+        >>> serializer.render(walker(token_stream))
+        '<html><head></head><body>Hi!</body></html>'
+
+        """
         if encoding:
             return b"".join(list(self.serialize(treewalker, encoding)))
         else:

From 21a6820957e677f24684ec84cddfecf1d541b11d Mon Sep 17 00:00:00 2001
From: Will Kahn-Greene <willkg@mozilla.com>
Date: Wed, 29 Nov 2017 14:39:01 -0500
Subject: [PATCH 021/105] 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 <willkg@mozilla.com>
Date: Wed, 29 Nov 2017 14:51:04 -0500
Subject: [PATCH 022/105] 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 <willkg@mozilla.com>
Date: Wed, 29 Nov 2017 15:08:19 -0500
Subject: [PATCH 023/105] 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('<html><body><p>This is a doc</p></body></html>')
+    <Element u'{http://www.w3.org/1999/xhtml}html' at 0x7feac4909db0>
+
+    """
     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('<b>this is a fragment</b>')
+    <Element u'DOCUMENT_FRAGMENT' at 0x7feac484b090>
+
+    """
     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('<html><body><p>This is a doc</p></body></html>')
+        <Element u'{http://www.w3.org/1999/xhtml}html' at 0x7feac4909db0>
 
-        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('<b>this is a fragment</b>')
+        <Element u'DOCUMENT_FRAGMENT' at 0x7feac484b090>
 
-        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 <hugovk@users.noreply.github.com>
Date: Sun, 3 Dec 2017 18:52:08 +0200
Subject: [PATCH 024/105] Via: git log --format="%aN" --reverse | perl -e 'my
 %dedupe; while (<STDIN>) { 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 <willkg@users.noreply.github.com>
Date: Sun, 3 Dec 2017 17:29:55 -0500
Subject: [PATCH 025/105] 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 ``<meta charset=ENCODING>`` 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>')
     #    => &lt;script> do_nasty_stuff() &lt;/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 <hugovk@users.noreply.github.com>
Date: Mon, 4 Dec 2017 23:43:46 +0200
Subject: [PATCH 026/105] 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 <willkg@users.noreply.github.com>
Date: Tue, 5 Dec 2017 19:11:26 -0500
Subject: [PATCH 027/105] 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 <geoffers@gmail.com>
Date: Thu, 7 Dec 2017 12:26:19 +0000
Subject: [PATCH 028/105] 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 <geoffers@gmail.com>
Date: Thu, 7 Dec 2017 13:56:29 +0000
Subject: [PATCH 029/105] 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 <geoffers@gmail.com>
Date: Thu, 7 Dec 2017 14:00:45 +0000
Subject: [PATCH 030/105] 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 <me@gsnedders.com>
Date: Tue, 16 Jan 2018 09:57:06 +0000
Subject: [PATCH 031/105] 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 <wbradt@optonline.net>
Date: Tue, 16 Jan 2018 04:57:52 -0500
Subject: [PATCH 032/105] 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 <wbradt@optonline.net>
Date: Sat, 20 Jan 2018 13:56:50 -0500
Subject: [PATCH 033/105] 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 <luzpaz@users.noreply.github.com>
Date: Mon, 5 Mar 2018 10:55:05 -0500
Subject: [PATCH 034/105] 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 <hugovk@users.noreply.github.com>
Date: Wed, 23 May 2018 12:50:20 +0300
Subject: [PATCH 035/105] 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 <hugovk@users.noreply.github.com>
Date: Wed, 23 May 2018 12:50:37 +0300
Subject: [PATCH 036/105] 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 <twm@freecog.net>
Date: Mon, 1 Oct 2018 04:28:12 -0700
Subject: [PATCH 037/105] 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 <jon.dufresne@gmail.com>
Date: Mon, 1 Oct 2018 06:30:13 -0500
Subject: [PATCH 038/105] 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 <jon.dufresne@gmail.com>
Date: Mon, 1 Oct 2018 06:31:35 -0500
Subject: [PATCH 039/105] 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 040/105] 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 <jon.dufresne@gmail.com>
Date: Tue, 16 Apr 2019 05:23:15 -0700
Subject: [PATCH 041/105] 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 <cclauss@me.com>
Date: Thu, 18 Apr 2019 15:53:07 +0200
Subject: [PATCH 042/105] 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 <Ms2ger@gmail.com>
Date: Fri, 26 Apr 2019 14:50:52 +0200
Subject: [PATCH 043/105] 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 <hugovk@users.noreply.github.com>
Date: Tue, 29 Oct 2019 19:13:40 +0100
Subject: [PATCH 044/105] 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 <jon.dufresne@gmail.com>
Date: Tue, 29 Oct 2019 11:17:28 -0700
Subject: [PATCH 045/105] 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 <jon.dufresne@gmail.com>
Date: Wed, 8 Jan 2020 19:54:13 -0800
Subject: [PATCH 046/105] 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 <jon.dufresne@gmail.com>
Date: Tue, 25 Feb 2020 16:46:50 -0800
Subject: [PATCH 047/105] 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 <jon.dufresne@gmail.com>
Date: Thu, 31 Oct 2019 18:50:29 -0700
Subject: [PATCH 048/105] 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
-# "<project> v<release> 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 <link> 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 <slev@altlinux.org>
Date: Thu, 30 May 2019 12:42:26 +0300
Subject: [PATCH 049/105] 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 <slev@altlinux.org>
---
 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 <jon.dufresne@gmail.com>
Date: Thu, 17 Oct 2019 21:16:22 -0700
Subject: [PATCH 050/105] 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 <jon.dufresne@gmail.com>
Date: Wed, 10 Oct 2018 20:11:15 -0700
Subject: [PATCH 051/105] 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 <meta charset>")
 
-    parser.add_option("", "--inject-meta-charset", action="store_true",
-                      default=False, dest="inject_meta_charset",
-                      help="inject <meta charset>")
+    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: ")_(" <zborboa@google.com>
Date: Tue, 25 Feb 2020 17:47:22 -0800
Subject: [PATCH 052/105] 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 <jon.dufresne@gmail.com>
Date: Tue, 1 Jan 2019 10:56:57 -0800
Subject: [PATCH 053/105] 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 <hugovk@users.noreply.github.com>
Date: Wed, 26 Feb 2020 16:04:56 +0200
Subject: [PATCH 054/105] 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 <me@gsnedders.com>
Date: Wed, 26 Feb 2020 15:20:43 +0000
Subject: [PATCH 055/105] 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 <me@gsnedders.com>
Date: Thu, 27 Feb 2020 17:05:43 +0000
Subject: [PATCH 056/105] 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 <jon.dufresne@gmail.com>
Date: Tue, 3 Mar 2020 10:02:57 -0800
Subject: [PATCH 057/105] 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
+<https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility>`_.
 
 Optional Dependencies
 ---------------------

From 2310bd8b610bc56a0521a6e8d96fedebcd15cc17 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <geoffers@gmail.com>
Date: Mon, 13 Apr 2020 05:59:31 +0100
Subject: [PATCH 058/105] 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 <me@gsnedders.com>
Date: Sat, 29 Feb 2020 13:19:49 +0000
Subject: [PATCH 059/105] 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 <me@gsnedders.com>
Date: Thu, 28 May 2020 16:26:44 +0100
Subject: [PATCH 060/105] 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 <me@gsnedders.com>
Date: Sun, 7 Jun 2020 17:51:33 +0100
Subject: [PATCH 061/105] 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[<!DOCTYPE HTML>\\n<script>document.write(\'<meta charset="ISO-8859-\' + \'2">\')</script>-iso-8859-2]': FAIL
+b'html5lib/tests/test_encoding.py::test_prescan_encoding[<!DOCTYPE HTML>\\n<script>document.write(\'<meta charset="ISO-8859-\' + \'2">\')</script>-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,
                    "<img title=\"1\"/>foo &lt;bad&gt;bar&lt;/bad&gt; baz",
                    "<%s title='1'>foo <bad>bar</bad> 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,
                    "<br title=\"1\"/>foo &lt;bad&gt;bar&lt;/bad&gt; baz<br/>",
                    "<%s title='1'>foo <bad>bar</bad> 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 &lt;bad&gt;bar&lt;/bad&gt; baz" % tag_name,
                    "<%s title='1'>foo <bad>bar</bad> 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 &lt;bad&gt;bar&lt;/bad&gt; baz</%s>" % (tag_name, tag_name),
                    "<%s title='1'>foo <bad>bar</bad> 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,
                "<p %s=\"%s\">foo &lt;bad&gt;bar&lt;/bad&gt; baz</p>" % (attribute_name, attribute_value),
                "<p %s='%s'>foo <bad>bar</bad> baz</p>" % (attribute_name, attribute_value))
 
@@ -101,7 +91,7 @@ def test_sanitizer():
         rest_of_uri = '//sub.domain.tld/path/object.ext'
         if protocol == 'data':
             rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ='
-        yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol,
+        yield ("test_should_allow_uppercase_%s_uris" % protocol,
                "<img src=\"%s:%s\">foo</a>" % (protocol, rest_of_uri),
                """<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
 
@@ -110,11 +100,26 @@ def test_sanitizer():
         if protocol == 'data':
             rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ='
         protocol = protocol.upper()
-        yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol,
+        yield ("test_should_allow_uppercase_%s_uris" % protocol,
                "<img src=\"%s:%s\">foo</a>" % (protocol, rest_of_uri),
                """<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
 
 
+@pytest.mark.parametrize("expected, input",
+                         (pytest.param(expected, input, id=id)
+                          for id, expected, input in param_sanitizer()))
+def test_sanitizer(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 test_lowercase_color_codes_in_style():
     sanitized = sanitize_html("<p style=\"border: 1px solid #a2a2a2;\"></p>")
     expected = '<p style=\"border: 1px solid #a2a2a2;\"></p>'
diff --git a/html5lib/tests/test_serializer.py b/html5lib/tests/test_serializer.py
index c23592af..bce62459 100644
--- a/html5lib/tests/test_serializer.py
+++ b/html5lib/tests/test_serializer.py
@@ -89,19 +89,6 @@ def serialize_html(input, options):
     return serializer.render(stream, encoding)
 
 
-def runSerializerTest(input, expected, options):
-    encoding = options.get("encoding", None)
-
-    if encoding:
-        expected = list(map(lambda x: x.encode(encoding), expected))
-
-    result = serialize_html(input, options)
-    if len(expected) == 1:
-        assert expected[0] == result, "Expected:\n%s\nActual:\n%s\nOptions:\n%s" % (expected[0], result, str(options))
-    elif result not in expected:
-        assert False, "Expected: %s, Received: %s" % (expected, result)
-
-
 def throwsWithLatin1(input):
     with pytest.raises(UnicodeEncodeError):
         serialize_html(input, {"encoding": "iso-8859-1"})
@@ -120,13 +107,13 @@ def testDoctypeSystemId():
 
 
 def testCdataCharacters():
-    runSerializerTest([["StartTag", "http://www.w3.org/1999/xhtml", "style", {}], ["Characters", "\u0101"]],
-                      ["<style>&amacr;"], {"encoding": "iso-8859-1"})
+    test_serializer([["StartTag", "http://www.w3.org/1999/xhtml", "style", {}], ["Characters", "\u0101"]],
+                    ["<style>&amacr;"], {"encoding": "iso-8859-1"})
 
 
 def testCharacters():
-    runSerializerTest([["Characters", "\u0101"]],
-                      ["&amacr;"], {"encoding": "iso-8859-1"})
+    test_serializer([["Characters", "\u0101"]],
+                    ["&amacr;"], {"encoding": "iso-8859-1"})
 
 
 def testStartTagName():
@@ -138,9 +125,9 @@ def testAttributeName():
 
 
 def testAttributeValue():
-    runSerializerTest([["StartTag", "http://www.w3.org/1999/xhtml", "span",
-                        [{"namespace": None, "name": "potato", "value": "\u0101"}]]],
-                      ["<span potato=&amacr;>"], {"encoding": "iso-8859-1"})
+    test_serializer([["StartTag", "http://www.w3.org/1999/xhtml", "span",
+                      [{"namespace": None, "name": "potato", "value": "\u0101"}]]],
+                    ["<span potato=&amacr;>"], {"encoding": "iso-8859-1"})
 
 
 def testEndTagName():
@@ -165,7 +152,7 @@ def testSpecQuoteAttribute(c):
     else:
         output_ = ['<span foo="%s">' % c]
     options_ = {"quote_attr_values": "spec"}
-    runSerializerTest(input_, output_, options_)
+    test_serializer(input_, output_, options_)
 
 
 @pytest.mark.parametrize("c", list("\t\n\u000C\x20\r\"'=<>`"
@@ -184,7 +171,7 @@ def testLegacyQuoteAttribute(c):
     else:
         output_ = ['<span foo="%s">' % c]
     options_ = {"quote_attr_values": "legacy"}
-    runSerializerTest(input_, output_, options_)
+    test_serializer(input_, output_, options_)
 
 
 @pytest.fixture
@@ -217,9 +204,23 @@ def testEntityNoResolve(lxml_parser):
     assert result == '<!DOCTYPE html SYSTEM "about:legacy-compat"><html>&beta;</html>'
 
 
-def test_serializer():
+def param_serializer():
     for filename in get_data_files('serializer-testdata', '*.test', os.path.dirname(__file__)):
         with open(filename) as fp:
             tests = json.load(fp)
             for test in tests['tests']:
-                yield runSerializerTest, test["input"], test["expected"], test.get("options", {})
+                yield test["input"], test["expected"], test.get("options", {})
+
+
+@pytest.mark.parametrize("input, expected, options", param_serializer())
+def test_serializer(input, expected, options):
+    encoding = options.get("encoding", None)
+
+    if encoding:
+        expected = list(map(lambda x: x.encode(encoding), expected))
+
+    result = serialize_html(input, options)
+    if len(expected) == 1:
+        assert expected[0] == result, "Expected:\n%s\nActual:\n%s\nOptions:\n%s" % (expected[0], result, str(options))
+    elif result not in expected:
+        assert False, "Expected: %s, Received: %s" % (expected, result)
diff --git a/html5lib/tests/test_treewalkers.py b/html5lib/tests/test_treewalkers.py
index 67fc89e5..81d5132c 100644
--- a/html5lib/tests/test_treewalkers.py
+++ b/html5lib/tests/test_treewalkers.py
@@ -61,24 +61,7 @@ def set_attribute_on_first_child(docfrag, name, value, treeName):
         setter['ElementTree'](docfrag)(name, value)
 
 
-def runTreewalkerEditTest(intext, expected, attrs_to_add, tree):
-    """tests what happens when we add attributes to the intext"""
-    treeName, treeClass = tree
-    if treeClass is None:
-        pytest.skip("Treebuilder not loaded")
-    parser = html5parser.HTMLParser(tree=treeClass["builder"])
-    document = parser.parseFragment(intext)
-    for nom, val in attrs_to_add:
-        set_attribute_on_first_child(document, nom, val, treeName)
-
-    document = treeClass.get("adapter", lambda x: x)(document)
-    output = treewalkers.pprint(treeClass["walker"](document))
-    output = attrlist.sub(sortattrs, output)
-    if output not in expected:
-        raise AssertionError("TreewalkerEditTest: %s\nExpected:\n%s\nReceived:\n%s" % (treeName, expected, output))
-
-
-def test_treewalker_six_mix():
+def param_treewalker_six_mix():
     """Str/Unicode mix. If str attrs added to tree"""
 
     # On Python 2.x string literals are of type str. Unless, like this
@@ -99,7 +82,25 @@ def test_treewalker_six_mix():
 
     for tree in sorted(treeTypes.items()):
         for intext, attrs, expected in sm_tests:
-            yield runTreewalkerEditTest, intext, expected, attrs, tree
+            yield intext, expected, attrs, tree
+
+
+@pytest.mark.parametrize("intext, expected, attrs_to_add, tree", param_treewalker_six_mix())
+def test_treewalker_six_mix(intext, expected, attrs_to_add, tree):
+    """tests what happens when we add attributes to the intext"""
+    treeName, treeClass = tree
+    if treeClass is None:
+        pytest.skip("Treebuilder not loaded")
+    parser = html5parser.HTMLParser(tree=treeClass["builder"])
+    document = parser.parseFragment(intext)
+    for nom, val in attrs_to_add:
+        set_attribute_on_first_child(document, nom, val, treeName)
+
+    document = treeClass.get("adapter", lambda x: x)(document)
+    output = treewalkers.pprint(treeClass["walker"](document))
+    output = attrlist.sub(sortattrs, output)
+    if output not in expected:
+        raise AssertionError("TreewalkerEditTest: %s\nExpected:\n%s\nReceived:\n%s" % (treeName, expected, output))
 
 
 @pytest.mark.parametrize("tree,char", itertools.product(sorted(treeTypes.items()), ["x", "\u1234"]))
diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py
index 6112d11d..1ef6e725 100644
--- a/html5lib/tests/tree_construction.py
+++ b/html5lib/tests/tree_construction.py
@@ -57,8 +57,6 @@ def _getParserTests(self, treeName, treeAPIs):
             item.add_marker(pytest.mark.parser)
             if namespaceHTMLElements:
                 item.add_marker(pytest.mark.namespaced)
-            if treeAPIs is None:
-                item.add_marker(pytest.mark.skipif(True, reason="Treebuilder not loaded"))
             yield item
 
     def _getTreeWalkerTests(self, treeName, treeAPIs):
@@ -69,8 +67,6 @@ def _getTreeWalkerTests(self, treeName, treeAPIs):
                               treeAPIs)
         item.add_marker(getattr(pytest.mark, treeName))
         item.add_marker(pytest.mark.treewalker)
-        if treeAPIs is None:
-            item.add_marker(pytest.mark.skipif(True, reason="Treebuilder not loaded"))
         yield item
 
 
@@ -84,12 +80,14 @@ def convertTreeDump(data):
 class ParserTest(pytest.Item):
     def __init__(self, name, parent, test, treeClass, namespaceHTMLElements):
         super(ParserTest, self).__init__(name, parent)
-        self.obj = lambda: 1  # this is to hack around skipif needing a function!
         self.test = test
         self.treeClass = treeClass
         self.namespaceHTMLElements = namespaceHTMLElements
 
     def runtest(self):
+        if self.treeClass is None:
+            pytest.skip("Treebuilder not loaded")
+
         p = html5parser.HTMLParser(tree=self.treeClass,
                                    namespaceHTMLElements=self.namespaceHTMLElements)
 
@@ -147,11 +145,13 @@ def repr_failure(self, excinfo):
 class TreeWalkerTest(pytest.Item):
     def __init__(self, name, parent, test, treeAPIs):
         super(TreeWalkerTest, self).__init__(name, parent)
-        self.obj = lambda: 1  # this is to hack around skipif needing a function!
         self.test = test
         self.treeAPIs = treeAPIs
 
     def runtest(self):
+        if self.treeAPIs is None:
+            pytest.skip("Treebuilder not loaded")
+
         p = html5parser.HTMLParser(tree=self.treeAPIs["builder"])
 
         input = self.test['data']
diff --git a/requirements-test.txt b/requirements-test.txt
index c3aa391d..703d0e69 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,39 +1,10 @@
 -r requirements.txt
 
-# make sure we have a deterministic test setup
-
-# pin all of our direct dependencies
-tox==3.14.5
-flake8==3.7.9
-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
-
-# 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
+tox>=3.15.1,<4
+flake8>=3.8.1,<3.9
+pytest>=4.6.10,<5 ; python_version < '3'
+pytest>=5.4.2,<6 ; python_version >= '3'
+coverage>=5.1,<6
+pytest-expect>=1.1.0,<2
+mock>=3.0.5,<4 ; python_version < '3.6'
+mock>=4.0.2,<5 ; python_version >= '3.6'

From dcf3f0b626eaac23684169506ff2e104ced03661 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Tue, 9 Jun 2020 01:07:53 +0100
Subject: [PATCH 062/105] Update html5lib-tests

---
 .pytest.expect          | 77 +++++++++++++++++++++--------------------
 html5lib/tests/testdata |  2 +-
 2 files changed, 41 insertions(+), 38 deletions(-)

diff --git a/.pytest.expect b/.pytest.expect
index 1b3705a7..4961b00f 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -2,20 +2,21 @@ pytest-expect file v1
 (2, 7, 18, 'final', 0)
 b'html5lib/tests/test_encoding.py::test_parser_encoding[<!DOCTYPE HTML>\\n<script>document.write(\'<meta charset="ISO-8859-\' + \'2">\')</script>-iso-8859-2]': FAIL
 b'html5lib/tests/test_encoding.py::test_prescan_encoding[<!DOCTYPE HTML>\\n<script>document.write(\'<meta charset="ISO-8859-\' + \'2">\')</script>-iso-8859-2]': FAIL
+u'html5lib/tests/testdata/tokenizer/domjs.test::4::cdataSectionState': 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
-u'html5lib/tests/testdata/tokenizer/test3.test::232::dataState': FAIL
-u'html5lib/tests/testdata/tokenizer/test3.test::234::dataState': FAIL
-u'html5lib/tests/testdata/tokenizer/test3.test::235::dataState': FAIL
-u'html5lib/tests/testdata/tokenizer/test3.test::237::dataState': FAIL
-u'html5lib/tests/testdata/tokenizer/test3.test::240::dataState': FAIL
-u'html5lib/tests/testdata/tokenizer/test3.test::241::dataState': FAIL
-u'html5lib/tests/testdata/tokenizer/test3.test::243::dataState': FAIL
-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/tokenizer/test3.test::280::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::283::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::284::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::286::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::287::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::289::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::292::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::293::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::295::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::296::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::298::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::310::dataState': FAIL
+u'html5lib/tests/testdata/tokenizer/test3.test::718::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
@@ -24,6 +25,14 @@ u'html5lib/tests/testdata/tree-construction/adoption01.dat::17::cElementTree::pa
 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/blocks.dat::12::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/blocks.dat::12::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
@@ -216,30 +225,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/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
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::4::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::5::cElementTree::parser::namespaced': FAIL
-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/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
@@ -1248,6 +1233,14 @@ u'html5lib/tests/testdata/tree-construction/tests11.dat::6::cElementTree::parser
 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/tests18.dat::15::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests18.dat::15::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
@@ -1296,6 +1289,16 @@ u'html5lib/tests/testdata/tree-construction/tests25.dat::7::cElementTree::parser
 u'html5lib/tests/testdata/tree-construction/tests25.dat::7::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/tests25.dat::7::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/tests25.dat::7::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests8.dat::5::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/webkit01.dat::22::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/webkit01.dat::22::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::ElementTree::parser::namespaced': FAIL
diff --git a/html5lib/tests/testdata b/html5lib/tests/testdata
index c305da74..71eebd59 160000
--- a/html5lib/tests/testdata
+++ b/html5lib/tests/testdata
@@ -1 +1 @@
-Subproject commit c305da74fae50fb018870de7a042da36c1a93b65
+Subproject commit 71eebd59772d1d39aced0c0582ae9c09acf3ce6e

From e749511d7a1d2b3323ff48115adfcfd5e2f20cf4 Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <hugovk@users.noreply.github.com>
Date: Tue, 9 Jun 2020 03:46:14 +0300
Subject: [PATCH 063/105] Test on Python 3.9-dev

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index c944f922..8082e05f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,7 @@ python:
   - "3.6"
   - "3.5"
   - "2.7"
+  - "3.9-dev"
 
 cache: pip
 

From 5c1a69557977ad6a75d71fcbd611e8941fce3001 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Fri, 22 May 2020 20:52:20 +0100
Subject: [PATCH 064/105] Fix #488: append document-child comments in document
 order in lxml

---
 .pytest.expect                      | 2 --
 html5lib/treebuilders/etree_lxml.py | 6 +++++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.pytest.expect b/.pytest.expect
index 4961b00f..22cf51bb 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -1297,8 +1297,6 @@ u'html5lib/tests/testdata/tree-construction/tests8.dat::5::cElementTree::parser:
 u'html5lib/tests/testdata/tree-construction/tests8.dat::5::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/tests8.dat::5::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/tests8.dat::5::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/webkit01.dat::22::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/webkit01.dat::22::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::ElementTree::parser::namespaced': FAIL
diff --git a/html5lib/treebuilders/etree_lxml.py b/html5lib/treebuilders/etree_lxml.py
index ca12a99c..227a0b24 100644
--- a/html5lib/treebuilders/etree_lxml.py
+++ b/html5lib/treebuilders/etree_lxml.py
@@ -44,7 +44,11 @@ def __init__(self):
         self._childNodes = []
 
     def appendChild(self, element):
-        self._elementTree.getroot().addnext(element._element)
+        last = self._elementTree.getroot()
+        for last in self._elementTree.getroot().itersiblings():
+            pass
+
+        last.addnext(element._element)
 
     def _getChildNodes(self):
         return self._childNodes

From d49afd350c06339a8c59299664b8a73a3b2c3f64 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Tue, 9 Jun 2020 01:58:19 +0100
Subject: [PATCH 065/105] Reduce number of Travis CI jobs

---
 .travis.yml | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8082e05f..6561e2a3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,10 +14,7 @@ cache: pip
 env:
   global:
     - PYTEST_COMMAND="coverage run -m pytest"
-  matrix:
-    - TOXENV=optional
-    - TOXENV=base
-    - TOXENV=six19-optional
+    - TOXENV=base,optional,six19-optional
 
 install:
   - pip install tox codecov

From 0fdd819fcf04d7e39d4eedd49e8d5a38aca0d75e Mon Sep 17 00:00:00 2001
From: Sam Sneddon <geoffers@gmail.com>
Date: Fri, 15 May 2020 04:39:24 +0100
Subject: [PATCH 066/105] Add some parser benchmarks

These tests are based on two things: some from WPT, and some based on Anolis
---
 benchmarks/bench_html.py                      |   57 +
 benchmarks/bench_wpt.py                       |   45 +
 benchmarks/data/README.md                     |    8 +
 benchmarks/data/html.html                     | 5000 +++++++++++++++++
 benchmarks/data/wpt/LICENSE.md                |   11 +
 benchmarks/data/wpt/README.md                 |   52 +
 benchmarks/data/wpt/random/001.html           |    3 +
 .../wpt/random/background-origin-007-ref.html |   18 +
 ...background_shorthand_css_relative_url.html |   24 +
 .../beforeunload-on-history-back-1.html       |    5 +
 .../data/wpt/random/euckr-encode-form.html    |   52 +
 .../random/frame-ancestors-self-allow.html    |   16 +
 benchmarks/data/wpt/random/grouping-dl.html   |   30 +
 .../data/wpt/random/heavy-styling-005.html    |   15 +
 benchmarks/data/wpt/random/htb-ltr-ltr.html   |   74 +
 benchmarks/data/wpt/random/idbindex_get8.htm  |   27 +
 benchmarks/data/wpt/random/idlharness.html    |   34 +
 .../wpt/random/li-type-unsupported-ref.html   |   13 +
 ...css21-float-page-break-inside-avoid-6.html |   19 +
 .../random/shape-outside-content-box-002.html |   66 +
 .../wpt/random/worker-constructor.https.html  |   86 +
 .../2d.composite.image.destination-over.html  |   33 +
 .../wpt/weighted/align-content-wrap-002.html  |  108 +
 .../data/wpt/weighted/big5_chars_extra.html   |    1 +
 benchmarks/data/wpt/weighted/fetch.http.html  |  143 +
 .../filter-turbulence-invalid-001.html        |   51 +
 .../wpt/weighted/grid-auto-fill-rows-001.html |  184 +
 ...ntation-from-image-content-images-ref.html |   86 +
 .../weighted/masonry-item-placement-006.html  |  149 +
 ...css21-table-page-break-inside-avoid-2.html |   29 +
 .../position-sticky-table-th-bottom-ref.html  |   62 +
 .../data/wpt/weighted/pre-float-001.html      |   36 +
 benchmarks/data/wpt/weighted/resize-004.html  |   20 +
 .../data/wpt/weighted/test-plan.src.html      | 1616 ++++++
 benchmarks/data/wpt/weighted/toBlob.png.html  |   17 +
 .../weighted/will-change-abspos-cb-001.html   |   30 +
 36 files changed, 8220 insertions(+)
 create mode 100644 benchmarks/bench_html.py
 create mode 100644 benchmarks/bench_wpt.py
 create mode 100644 benchmarks/data/README.md
 create mode 100644 benchmarks/data/html.html
 create mode 100644 benchmarks/data/wpt/LICENSE.md
 create mode 100644 benchmarks/data/wpt/README.md
 create mode 100644 benchmarks/data/wpt/random/001.html
 create mode 100644 benchmarks/data/wpt/random/background-origin-007-ref.html
 create mode 100644 benchmarks/data/wpt/random/background_shorthand_css_relative_url.html
 create mode 100644 benchmarks/data/wpt/random/beforeunload-on-history-back-1.html
 create mode 100644 benchmarks/data/wpt/random/euckr-encode-form.html
 create mode 100644 benchmarks/data/wpt/random/frame-ancestors-self-allow.html
 create mode 100644 benchmarks/data/wpt/random/grouping-dl.html
 create mode 100644 benchmarks/data/wpt/random/heavy-styling-005.html
 create mode 100644 benchmarks/data/wpt/random/htb-ltr-ltr.html
 create mode 100644 benchmarks/data/wpt/random/idbindex_get8.htm
 create mode 100644 benchmarks/data/wpt/random/idlharness.html
 create mode 100644 benchmarks/data/wpt/random/li-type-unsupported-ref.html
 create mode 100644 benchmarks/data/wpt/random/moz-css21-float-page-break-inside-avoid-6.html
 create mode 100644 benchmarks/data/wpt/random/shape-outside-content-box-002.html
 create mode 100644 benchmarks/data/wpt/random/worker-constructor.https.html
 create mode 100644 benchmarks/data/wpt/weighted/2d.composite.image.destination-over.html
 create mode 100644 benchmarks/data/wpt/weighted/align-content-wrap-002.html
 create mode 100644 benchmarks/data/wpt/weighted/big5_chars_extra.html
 create mode 100644 benchmarks/data/wpt/weighted/fetch.http.html
 create mode 100644 benchmarks/data/wpt/weighted/filter-turbulence-invalid-001.html
 create mode 100644 benchmarks/data/wpt/weighted/grid-auto-fill-rows-001.html
 create mode 100644 benchmarks/data/wpt/weighted/image-orientation-from-image-content-images-ref.html
 create mode 100644 benchmarks/data/wpt/weighted/masonry-item-placement-006.html
 create mode 100644 benchmarks/data/wpt/weighted/moz-css21-table-page-break-inside-avoid-2.html
 create mode 100644 benchmarks/data/wpt/weighted/position-sticky-table-th-bottom-ref.html
 create mode 100644 benchmarks/data/wpt/weighted/pre-float-001.html
 create mode 100644 benchmarks/data/wpt/weighted/resize-004.html
 create mode 100644 benchmarks/data/wpt/weighted/test-plan.src.html
 create mode 100644 benchmarks/data/wpt/weighted/toBlob.png.html
 create mode 100644 benchmarks/data/wpt/weighted/will-change-abspos-cb-001.html

diff --git a/benchmarks/bench_html.py b/benchmarks/bench_html.py
new file mode 100644
index 00000000..cfe53c67
--- /dev/null
+++ b/benchmarks/bench_html.py
@@ -0,0 +1,57 @@
+import io
+import os
+import sys
+
+import pyperf
+
+sys.path[0:0] = [os.path.join(os.path.dirname(__file__), "..")]
+import html5lib  # noqa: E402
+
+
+def bench_parse(fh, treebuilder):
+    fh.seek(0)
+    html5lib.parse(fh, treebuilder=treebuilder, useChardet=False)
+
+
+def bench_serialize(loops, fh, treebuilder):
+    fh.seek(0)
+    doc = html5lib.parse(fh, treebuilder=treebuilder, useChardet=False)
+
+    range_it = range(loops)
+    t0 = pyperf.perf_counter()
+
+    for loops in range_it:
+        html5lib.serialize(doc, tree=treebuilder, encoding="ascii", inject_meta_charset=False)
+
+    return pyperf.perf_counter() - t0
+
+
+BENCHMARKS = ["parse", "serialize"]
+
+
+def add_cmdline_args(cmd, args):
+    if args.benchmark:
+        cmd.append(args.benchmark)
+
+
+if __name__ == "__main__":
+    runner = pyperf.Runner(add_cmdline_args=add_cmdline_args)
+    runner.metadata["description"] = "Run benchmarks based on Anolis"
+    runner.argparser.add_argument("benchmark", nargs="?", choices=BENCHMARKS)
+
+    args = runner.parse_args()
+    if args.benchmark:
+        benchmarks = (args.benchmark,)
+    else:
+        benchmarks = BENCHMARKS
+
+    with open(os.path.join(os.path.dirname(__file__), "data", "html.html"), "rb") as fh:
+        source = io.BytesIO(fh.read())
+
+    if "parse" in benchmarks:
+        for tb in ("etree", "dom", "lxml"):
+            runner.bench_func("html_parse_%s" % tb, bench_parse, source, tb)
+
+    if "serialize" in benchmarks:
+        for tb in ("etree", "dom", "lxml"):
+            runner.bench_time_func("html_serialize_%s" % tb, bench_serialize, source, tb)
diff --git a/benchmarks/bench_wpt.py b/benchmarks/bench_wpt.py
new file mode 100644
index 00000000..d5da0069
--- /dev/null
+++ b/benchmarks/bench_wpt.py
@@ -0,0 +1,45 @@
+import io
+import os
+import sys
+
+import pyperf
+
+sys.path[0:0] = [os.path.join(os.path.dirname(__file__), "..")]
+import html5lib  # noqa: E402
+
+
+def bench_html5lib(fh):
+    fh.seek(0)
+    html5lib.parse(fh, treebuilder="etree", useChardet=False)
+
+
+def add_cmdline_args(cmd, args):
+    if args.benchmark:
+        cmd.append(args.benchmark)
+
+
+BENCHMARKS = {}
+for root, dirs, files in os.walk(os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "wpt")):
+    for f in files:
+        if f.endswith(".html"):
+            BENCHMARKS[f[: -len(".html")]] = os.path.join(root, f)
+
+
+if __name__ == "__main__":
+    runner = pyperf.Runner(add_cmdline_args=add_cmdline_args)
+    runner.metadata["description"] = "Run parser benchmarks from WPT"
+    runner.argparser.add_argument("benchmark", nargs="?", choices=sorted(BENCHMARKS))
+
+    args = runner.parse_args()
+    if args.benchmark:
+        benchmarks = (args.benchmark,)
+    else:
+        benchmarks = sorted(BENCHMARKS)
+
+    for bench in benchmarks:
+        name = "wpt_%s" % bench
+        path = BENCHMARKS[bench]
+        with open(path, "rb") as fh:
+            fh2 = io.BytesIO(fh.read())
+
+        runner.bench_func(name, bench_html5lib, fh2)
diff --git a/benchmarks/data/README.md b/benchmarks/data/README.md
new file mode 100644
index 00000000..5b896cbb
--- /dev/null
+++ b/benchmarks/data/README.md
@@ -0,0 +1,8 @@
+The files in this data are derived from:
+
+ * `html.html`: from [html](http://github.com/whatwg/html), revision
+   77db356a293f2b152b648c836b6989d17afe42bb. This is the first 5000 lines of `source`. (This is
+   representative of the input to [Anolis](https://bitbucket.org/ms2ger/anolis/); first 5000 lines
+   chosen to make it parse in a reasonable time.)
+
+ * `wpt`: see `wpt/README.md`.
diff --git a/benchmarks/data/html.html b/benchmarks/data/html.html
new file mode 100644
index 00000000..d2bb1be7
--- /dev/null
+++ b/benchmarks/data/html.html
@@ -0,0 +1,5000 @@
+<!-- EDITOR NOTES  -*- mode: Text; fill-column: 100 -*-
+ !
+ !   Adding a new element involves editing the following sections:
+ !    - section for the element itself
+ !    - descriptions of the element's categories
+ !    - images/content-venn.svg
+ !    - syntax, if it's void or otherwise special
+ !    - parser, if it's not phrasing-level
+ !    - rendering
+ !    - obsolete section
+ !    - element, attribute, content model, and interface indexes
+ !    - adding it to the section with ARIA mappings
+ !
+ !-->
+
+<!--
+ ! http://lists.w3.org/Archives/Public/www-archive/2014Apr/0034.html
+ !-->
+
+<!--START complete--><!--START dev-html-->
+<!DOCTYPE html>
+<!--SET FINGERPRINT=<span title="fingerprinting vector" class="fingerprint"><img src="images/fingerprint.png" alt="(This is a fingerprinting vector.)" width=46 height=64></span>-->
+<html lang="en-GB-x-hixie" class="big">
+ <head>
+  <title>HTML Standard</title>
+  <script>
+   var loadTimer = new Date();
+   var current_revision = "r" + "$Revision: 1 $".substr(11);
+   current_revision = current_revision.substr(0, current_revision.length - 2);
+   var last_known_revision = current_revision;
+   function F( /* varargs... */) {
+     var fragment = document.createDocumentFragment();
+     for (var index = 0; index < arguments.length; index += 1) {
+       if (arguments[index] instanceof Array) {
+         fragment.appendChild(F.apply(this, arguments[index]));
+       } else if (typeof arguments[index] == 'string') {
+         fragment.appendChild(document.createTextNode(arguments[index]));
+       } else {
+         fragment.appendChild(arguments[index]);
+       }
+     }
+     return fragment;
+   }
+   function E(name, /* optional */ attributes /*, varargs... */) {
+     var element = document.createElement(name);
+     var index = 1;
+     if ((arguments.length > 1) && (typeof attributes != 'string') &&
+         (!(attributes instanceof Node)) && (!(attributes instanceof Array))) {
+       for (var attName in attributes) {
+         if (typeof attributes[attName] == 'boolean') {
+           if (attributes[attName])
+             element.setAttribute(attName, '');
+         } else if (typeof attributes[attName] == 'function') {
+           element[attName] = attributes[attName];
+         } else {
+           element.setAttribute(attName, attributes[attName]);
+         }
+       }
+       index = 2;
+     }
+     for (; index < arguments.length; index += 1) {
+       if (arguments[index] instanceof Array) {
+         element.appendChild(F.apply(this, arguments[index]));
+       } else if (typeof arguments[index] == 'string') {
+         element.appendChild(document.createTextNode(arguments[index]));
+       } else {
+         element.appendChild(arguments[index]);
+       }
+     }
+     return element;
+   }
+   function getCookie(name) {
+     var params = location.search.substr(1).split("&");
+     for (var index = 0; index < params.length; index++) {
+       if (params[index] == name)
+         return "1";
+       var data = params[index].split("=");
+       if (data[0] == name)
+         return unescape(data[1]);
+     }
+     var cookies = document.cookie.split("; ");
+     for (var index = 0; index < cookies.length; index++) {
+       var data = cookies[index].split("=");
+       if (data[0] == name)
+         return unescape(data[1]);
+     }
+     return null;
+   }
+   var currentAlert;
+   var currentAlertTimeout;
+   function showAlert(s, href) {
+     if (!currentAlert) {
+       currentAlert = document.createElement('div');
+       currentAlert.id = 'alert';
+       var x = document.createElement('button');
+       x.textContent = '\u2573';
+       x.onclick = closeAlert2;
+       currentAlert.appendChild(x);
+       currentAlert.appendChild(document.createElement('span'));
+       currentAlert.onmousemove = function () {
+         clearTimeout(currentAlertTimeout);
+         currentAlert.className = '';
+         currentAlertTimeout = setTimeout(closeAlert, 10000);
+       }
+       document.body.appendChild(currentAlert);
+     } else {
+       clearTimeout(currentAlertTimeout);
+       currentAlert.className = '';
+     }
+     currentAlert.lastChild.textContent = '';
+     currentAlert.lastChild.appendChild(F(s));
+     if (href) {
+       var link = document.createElement('a');
+       link.href = href;
+       link.textContent = href;
+       currentAlert.lastChild.appendChild(F(' ', link));
+     }
+     currentAlertTimeout = setTimeout(closeAlert, 10000);
+   }
+   function closeAlert() {
+     clearTimeout(currentAlertTimeout);
+     if (currentAlert) {
+       currentAlert.className = 'closed';
+       currentAlertTimeout = setTimeout(closeAlert2, 3000);
+     }
+   }
+   function closeAlert2() {
+     clearTimeout(currentAlertTimeout);
+     if (currentAlert) {
+       currentAlert.parentNode.removeChild(currentAlert);
+       currentAlert = null;
+     }
+   }
+   window.addEventListener('keydown', function (event) {
+     if (event.keyCode == 27) {
+       if (currentAlert)
+         closeAlert2();
+     } else {
+       closeAlert();
+     }
+   }, false);
+   window.addEventListener('scroll', function (event) {
+     closeAlert();
+   }, false);
+   function load(script) {
+     var e = document.createElement('script');
+     e.setAttribute('src', '//www.whatwg.org/specs/web-apps/current-work/' + script);
+     document.body.appendChild(e);
+   }
+
+   var startedInit = 0;
+   function init() {
+     startedInit = 1;
+     if (location.search == '?slow-browser')
+       return;
+     load('reviewer.js');
+     if (document.documentElement.className == "big" || document.documentElement.className == "big split index")
+       load('toc.js');
+     load('updater.js');
+     load('dfn.js');
+     load('status.js');
+     if (getCookie('profile') == '1')
+       document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
+   }
+   if (document.documentElement.className == "")
+     setTimeout(function () {
+       if (!startedInit)
+         showAlert("Too slow? Try reading the multipage copy of the spec instead:", "http://whatwg.org/html");
+     }, 6000);
+
+   window.addEventListener('keypress', function (event) {
+     if ((event.which == 114) && (event.metaKey)) {
+       if (!confirm('Are you sure you want to reload this page?'))
+         event.preventDefault();
+     }
+   }, false);
+
+  </script>
+  <link rel="stylesheet" href="//www.whatwg.org/style/specification">
+  <link rel="icon" href="//www.whatwg.org/images/icon">
+  <style>
+   .proposal { border: blue solid; padding: 1em; }
+   .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
+   #updatesStatus { display: none; z-index: 10; }
+   #updatesStatus.relevant { display: block; position: fixed; right: 1em; top: 1em; padding: 0.5em; font: bold small sans-serif; min-width: 25em; width: 30%; max-width: 40em; height: auto; border: ridge 4px gray; background: #EEEEEE; color: black; }
+   div.head .logo { width: 11em; margin-bottom: 20em; }
+
+   #configUI { position: absolute; z-index: 20; top: auto; right: 0; width: 11em; padding: 0 0.5em 0 0.5em; font-size: small; background: gray; background: rgba(32,32,32,0.9); color: white; border-radius: 1em 0 0 1em; -moz-border-radius: 1em 0 0 1em; }
+   #configUI p { margin: 0.75em 0; padding: 0.3em; }
+   #configUI p label { display: block; }
+   #configUI #updateUI, #configUI .loginUI { text-align: center; }
+   #configUI input[type=button] { display: block; margin: auto; }
+   #configUI :link, #configUI :visited { color: white; }
+   #configUI :link:hover, #configUI :visited:hover { background: transparent; }
+
+   #alert { position: fixed; top: 20%; left: 20%; right: 20%; font-size: 2em; padding: 0.5em; z-index: 40; background: gray; background: rgba(32,32,32,0.9); color: white; border-radius: 1em; -moz-border-radius: 1em; -webkit-transition: opacity 1s linear; }
+   #alert.closed { opacity: 0; }
+   #alert button { position: absolute; top: -1em; right: 2em; border-radius: 1em 1em 0 0; border: none; line-height: 0.9; color: white; background: rgb(64,64,64); font-size: 0.6em; font-weight: 900; cursor: pointer; }
+   #alert :link, #alert :visited { color: white; }
+   #alert :link:hover, #alert :visited:hover { background: transparent; }
+   @media print { #configUI { display: none; } }
+
+   .rfc2119 { font-variant: small-caps; text-shadow: 0 0 0.5em yellow; position: static; }
+   .rfc2119::after { position: absolute; left: 0; width: 25px; text-align: center; color: yellow; text-shadow: 0.075em 0.075em 0.2em black; }
+   .rfc2119.m\ust::after { content: '\2605'; }
+   .rfc2119.s\hould::after { content: '\2606'; }
+   [hidden] { display: none; }
+
+   .fingerprint { float: right; }
+
+   .applies thead th > * { display: block; }
+   .applies thead code { display: block; }
+   .applies td { text-align: center; }
+   .applies .yes { background: yellow; }
+
+   .matrix, .matrix td { border: hidden; text-align: right; }
+   .matrix { margin-left: 2em; }
+
+   .vertical-summary-table tr > th[rowspan="2"]:first-child + th,
+   .vertical-summary-table tr > td[rowspan="2"]:first-child + td { border-bottom: hidden; }
+
+   .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
+   .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
+   .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
+
+   td.eg { border-width: thin; text-align: center; }
+
+   #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
+   #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
+   #table-example-1 caption { padding-bottom: 0.5em; }
+   #table-example-1 thead, #table-example-1 tbody { border: none; }
+   #table-example-1 th, #table-example-1 td { border: solid thin; }
+   #table-example-1 th { font-weight: normal; }
+   #table-example-1 td { border-style: none solid; vertical-align: top; }
+   #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
+   #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
+   #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
+   #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
+   #table-example-1 tbody td:first-child::after { content: leader(". "); }
+   #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
+   #table-example-1 tbody td:first-child + td { width: 10em; }
+   #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
+   #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
+
+   .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
+   .apple-table-examples * { font-family: "Times", serif; }
+   .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
+   .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
+   .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
+   .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
+   .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
+   .apple-table-examples td { text-align: right; vertical-align: top; }
+   .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
+   .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
+   .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
+   .apple-table-examples sup { line-height: 0; }
+
+   .three-column-nowrap tr > td:first-child,
+   .three-column-nowrap tr > td:first-child + td,
+   .three-column-nowrap tr > td:first-child + td + td { white-space: nowrap; }
+
+   .details-example img { vertical-align: top; }
+
+   #base64-table {
+     white-space: nowrap;
+     font-size: 0.6em;
+     column-width: 6em;
+     column-count: 5;
+     column-gap: 1em;
+     -moz-column-width: 6em;
+     -moz-column-count: 5;
+     -moz-column-gap: 1em;
+     -webkit-column-width: 6em;
+     -webkit-column-count: 5;
+     -webkit-column-gap: 1em;
+   }
+   #base64-table thead { display: none; }
+   #base64-table * { border: none; }
+   #base64-table tbody td:first-child:after { content: ':'; }
+   #base64-table tbody td:last-child { text-align: right; }
+
+   #named-character-references-table {
+     white-space: nowrap;
+     font-size: 0.6em;
+     column-width: 30em;
+     column-gap: 1em;
+     -moz-column-width: 30em;
+     -moz-column-gap: 1em;
+     -webkit-column-width: 30em;
+     -webkit-column-gap: 1em;
+   }
+   #named-character-references-table > table > tbody > tr > td:first-child + td,
+   #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
+   #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
+   #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
+
+   .glyph.control { color: red; }
+
+   @font-face {
+     font-family: 'Essays1743';
+     src: url('//www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
+   }
+   @font-face {
+     font-family: 'Essays1743';
+     font-weight: bold;
+     src: url('//www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
+   }
+   @font-face {
+     font-family: 'Essays1743';
+     font-style: italic;
+     src: url('//www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
+   }
+   @font-face {
+     font-family: 'Essays1743';
+     font-style: italic;
+     font-weight: bold;
+     src: url('//www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
+   }
+  </style>
+  <link rel="stylesheet" href="status.css">
+ </head>
+ <body onload="init()">
+  <header class="head with-buttons" id="head">
+   <p><a href="//www.whatwg.org/" class="logo"><img width="101" height="101" alt="WHATWG" src="/images/logo"></a></p>
+   <hgroup>
+    <h1 class="allcaps">HTML</h1>
+    <h2 class="no-num no-toc">Living Standard &mdash; Last Updated <span class="pubdate">[DATE: 01 Jan 1901]</span></h2>
+   </hgroup>
+   <div>
+    <div>
+     <a href="//whatwg.org/html"><span><strong>Multipage Version</strong> <code>whatwg.org/html</code></span></a>
+     <a href="//whatwg.org/c"><span><strong>One-Page Version</strong> <code>whatwg.org/c</code></span></a>
+     <a href="//whatwg.org/pdf"><span><strong>PDF Version</strong> <code>whatwg.org/pdf</code></span></a>
+     <a href="http://developers.whatwg.org/"><span><strong>Developer Version</strong> <code>developers.whatwg.org</code></span></a>
+    </div>
+    <div>
+     <a class="misc" href="//whatwg.org/faq"><span><strong>FAQ</strong> <code>whatwg.org/faq</code></span></a>
+     <a class="misc" href="http://validator.whatwg.org/"><span><strong>Validators</strong> <code>validator.whatwg.org</code></span></a>
+    </div>
+    <div>
+     <a class="comms" href="//www.whatwg.org/mailing-list"><span><strong>Join our Mailing List</strong> <code>whatwg@whatwg.org</code></span></a>
+     <a class="comms" href="http://wiki.whatwg.org/wiki/IRC"><span><strong>Join us on IRC</strong> <code>#whatwg on Freenode</code></span></a>
+     <a class="comms" href="http://forums.whatwg.org/"><span><strong>Join our Forums</strong> <code>forums.whatwg.org</code></span></a>
+    </div>
+    <div>
+     <!--<a class="changes" href="http://svn.whatwg.org/webapps"><span><strong>SVN Repository</strong> <code>svn.whatwg.org/webapps</code></span></a>-->
+     <a class="changes" href="http://html5.org/tools/web-apps-tracker"><span><strong>Change Log</strong> <code>html5.org's tracker</code></span></a>
+     <a class="changes" href="http://twitter.com/WHATWG"><span><strong>Twitter Updates</strong> <code>@WHATWG</code></span></a>
+    </div>
+    <div>
+     <a class="feedback" href="https://www.w3.org/Bugs/Public/buglist.cgi?bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;component=HTML&amp;product=WHATWG"><span><strong>View Open Bugs</strong> <code>filed in Bugzilla</code></span></a>
+     <a class="feedback" href="//www.whatwg.org/newbug"><span><strong>File a Bug</strong> <code>whatwg.org/newbug</code></span></a>
+     <a class="feedback" href="http://ian.hixie.ch/+"><span><strong>E-mail the Editor</strong> <code>ian@hixie.ch</code></span></a>
+    </div>
+   </div>
+  </header>
+
+  <hr>
+
+  <div id="configUI"></div>
+
+  <h2 class="no-num no-toc" id="contents">Table of contents</h2>
+  <!--toc-->
+
+  <hr>
+
+<!--
+  <pre class="idl">
+   interface Screen { }; // CSSOM
+   interface URL { }; // URL API
+   interface Blob { }; // File API
+   interface File : Blob { }; // File API
+   interface FileList { }; // File API
+   interface WebGLRenderingContext { }; // WebGL
+   interface XMLDocument { }; // DOM
+   interface HTMLCollection { }; // DOM
+   interface DOMTokenList { }; // DOM
+   interface DOMSettableTokenList { attribute any value; }; // DOM
+   interface SVGMatrix { }; // SVG
+   // fake interfaces that map to JS object types:
+   interface ArrayBuffer { };
+   interface Int8Array { };
+   interface Uint8Array { };
+   interface Uint8ClampedArray { };
+   interface Int16Array { };
+   interface Uint16Array { };
+   interface Int32Array { };
+   interface Uint32Array { };
+   interface Float32Array { };
+   interface Float64Array { };
+   interface Uint8ClampedArray { };
+  </pre>
+-->
+
+  <h2 id="introduction">Introduction</h2>
+
+  <div class="nodev">
+
+  <h3 id="abstract">Where does this specification fit?</h3>
+
+  <p>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:</p>
+
+  <p><img src="images/abstract.png" width="398" height="359" alt="It consists of everything else, above such core technologies as HTTP, URI/IRIs, DOM, XML, Unicode, and ECMAScript; below presentation-layer technologies like CSS and the NPAPI; and to the side of technologies like Geolocation, SVG, MathML, and XHR."></p>
+
+  </div>
+
+
+  <h3 id="is-this-html5?">Is this HTML5?</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>In short: Yes.</p>
+
+  <p>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 <a href="http://www.whatwg.org/specs/">the WHATWG
+  specification index</a>.</p>
+
+  <p class="note">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.</p>
+
+
+  <h3>Background</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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.</p>
+
+
+  <h3>Audience</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>This specification is intended for authors of documents and scripts that use the features
+  defined in this specification<span class="nodev">, 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</span>.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+
+  <h3>Scope</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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.</p>
+
+  <p>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).</p>
+
+  <p>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.</p>
+
+
+  <h3>History</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>The following year, the W3C membership decided to stop evolving HTML and instead begin work on
+  an XML-based equivalent, called XHTML. <!-- http://www.w3.org/MarkUp/future/#summary --> 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.</p>
+
+  <p>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.</p>
+
+  <p>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).</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+
+
+  <h3>Design notes</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>It must be admitted that many aspects of HTML appear at first glance to be nonsensical and
+  inconsistent.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>Despite all this, efforts have been made to adhere to certain design goals. These are described
+  in the next few subsections.</p>
+
+
+
+  <h4>Serializability of script execution</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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 <span data-x="Worker">workers</span>, the intent is that the behavior of implementations can
+  be thought of as completely serializing the execution of all scripts in all <span data-x="browsing
+  context">browsing contexts</span>.</p>
+
+  <p class="note">The <code
+  data-x="dom-navigator-yieldForStorageUpdates">navigator.yieldForStorageUpdates()</code> method, in
+  this model, is equivalent to allowing other scripts to run while the calling script is
+  blocked.</p>
+
+
+
+  <h4>Compliance with other specifications</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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 "<dfn>willful violation</dfn>", and the reason for the violation has
+  been noted.</p>
+
+
+
+  <h4>Extensibility</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>HTML has a wide array of extensibility mechanisms that can be used for adding semantics in a
+  safe manner:</p>
+
+  <ul>
+
+   <li><p>Authors can use the <code data-x="attr-class">class</code> 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.</p></li>
+
+   <li><p>Authors can include data for inline client-side scripts or server-side site-wide scripts
+   to process using the <code data-x="attr-data-*">data-*=""</code> 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.</p></li>
+
+   <li><p>Authors can use the <code data-x="meta">&lt;meta name="" content=""></code> mechanism to
+   include page-wide metadata by registering <span data-x="concept-meta-extensions">extensions to
+   the predefined set of metadata names</span>.</p></li>
+
+   <li><p>Authors can use the <code data-x="attr-hyperlink-rel">rel=""</code> mechanism to annotate
+   links with specific meanings by registering <span data-x="concept-rel-extensions">extensions to
+   the predefined set of link types</span>. This is also used by microformats.</p></li>
+
+   <li><p>Authors can embed raw data using the <code data-x="script">&lt;script type=""></code>
+   mechanism with a custom type, for further handling by inline or server-side scripts.</p></li>
+
+   <li><p>Authors can create <span data-x="plugin">plugins</span> and invoke them using the
+   <code>embed</code> element. This is how Flash works.</p></li>
+
+   <li><p>Authors can extend APIs using the JavaScript prototyping mechanism. This is widely used by
+   script libraries, for instance.</p></li>
+
+   <li><p>Authors can use the microdata feature (the <code
+   data-x="attr-itemscope">itemscope=""</code> and <code data-x="attr-itemprop">itemprop=""</code>
+   attributes) to embed nested name-value pairs of data to be shared with other applications and
+   sites.</p></li>
+
+  </ul>
+
+
+
+
+  <h3>HTML vs XHTML</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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.</p>
+
+  <p>The in-memory representation is known as "DOM HTML", or "the DOM" for short.</p>
+
+  <p>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.</p>
+
+  <p>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
+  <code>text/html</code> <span>MIME type</span>, then it will be processed as an HTML document by
+  Web browsers. This specification defines the latest HTML syntax, known simply as "HTML".</p>
+
+  <p>The second concrete syntax is the XHTML syntax, which is an application of XML. When a document
+  is transmitted with an <span>XML MIME type</span>, such as <code>application/xhtml+xml</code>,
+  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".</p>
+
+  <p>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 <code>noscript</code> 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 "<code data-x="">--&gt;</code>" can only be represented in the
+  DOM, not in the HTML and XHTML syntaxes.</p>
+
+
+  <h3>Structure of this specification</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>This specification is divided into the following major sections:</p>
+
+  <dl>
+
+
+   <dt><a href="#introduction">Introduction</a></dt>
+
+   <dd>Non-normative materials providing a context for the HTML standard.</dd>
+
+
+   <dt><a href="#infrastructure">Common infrastructure</a></dt>
+
+   <dd>The conformance classes, algorithms, definitions, and the common underpinnings of the rest of
+   the specification.</dd>
+
+
+   <dt><a href="#dom">Semantics, structure, and APIs of HTML documents</a></dt>
+
+   <dd>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.</dd>
+
+
+   <dt><a href="#semantics">The elements of HTML</a></dt>
+
+   <dd>Each element has a predefined meaning, which is explained in this section. Rules for authors
+   on how to use the element<span class="nodev">, along with user agent requirements for how to
+   handle each element,</span> 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.</dd>
+
+
+   <dt><a href="#microdata">Microdata</a></dt>
+
+   <dd>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<span class="nodev"> and some algorithms that can be used to convert HTML
+   documents into other formats</span>. This section also defines some sample Microdata vocabularies
+   for contact information, calendar events, and licensing works.</dd>
+
+
+   <dt><a href="#editing">User interaction</a></dt>
+
+   <dd>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.</dd>
+
+
+   <dt><a href="#browsers">Loading Web pages</a></dt>
+
+   <dd>HTML documents do not exist in a vacuum &mdash; 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.</dd>
+
+
+   <dt><a href="#webappapis">Web application APIs</a></dt>
+
+   <dd>This section introduces basic features for scripting of applications in HTML.</dd>
+
+
+   <dt><a href="#workers">Web workers</a></dt>
+
+   <dd>This section defines an API for background threads in JavaScript.</dd>
+
+
+   <dt><a href="#comms">The communication APIs</a></dt>
+
+   <dd>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
+   <code>EventSource</code>, and a two-way full-duplex socket protocol for scripts known as Web
+   Sockets.
+
+   </dd>
+
+
+   <dt><a href="#webstorage">Web storage</a></dt>
+
+   <dd>This section defines a client-side storage mechanism based on name-value pairs.</dd>
+
+
+   <dt><a href="#syntax">The HTML syntax</a></dt>
+   <dt><a href="#xhtml">The XHTML syntax</a></dt>
+
+   <dd>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<span
+   class="nodev">, along with rules for how to parse content using those syntaxes</span>.</dd>
+
+
+   <dt><a href="#rendering">Rendering</a></dt>
+
+   <dd>This section defines the default rendering rules for Web browsers.</dd>
+
+
+  </dl>
+
+  <p>There are also some appendices, listing <a href="#obsolete">obsolete features</a> and <a
+  href="#iana">IANA considerations</a>, and several indices.</p>
+
+
+
+  <h4>How to read this specification</h4>
+
+  <p>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.</p>
+
+  <p>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 <em>producers</em>, for example authors and the documents they create,
+  and there are conformance requirements that apply to <em>consumers</em>, 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.</p>
+
+  <div class="example">
+
+   <p>For example, "the <code data-x="">foo</code> attribute's value must be a <span>valid
+   integer</span>" is a requirement on producers, as it lays out the allowed values; in contrast,
+   the requirement "the <code data-x="">foo</code> attribute's value must be parsed using the
+   <span>rules for parsing integers</span>" is a requirement on consumers, as it describes how to
+   process the content.</p>
+
+  </div>
+
+  <p><strong>Requirements on producers have no bearing whatsoever on consumers.</strong></p>
+
+  <div class="example">
+
+   <p>Continuing the above example, a requirement stating that a particular attribute's value is
+   constrained to being a <span>valid integer</span> emphatically does <em>not</em> 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.</p>
+
+  </div>
+
+
+
+  <h4>Typographic conventions</h4>
+
+  <p>This is a definition, requirement, or explanation.</p>
+
+  <p class="note">This is a note.</p>
+
+  <p class="example">This is an example.</p>
+
+  <p class="&#x0058;&#x0058;&#x0058;">This is an open issue.</p>
+
+  <p class="warning">This is a warning.</p>
+
+  <pre class="idl extract">interface <dfn data-x="">Example</dfn> {
+  // this is an IDL definition
+};</pre>
+
+  <dl class="domintro">
+
+   <dt><var data-x="">variable</var> = <var data-x="">object</var> . <code data-x="">method</code>( [ <var data-x="">optionalArgument</var> ] )</dt>
+
+   <dd>
+
+    <p>This is a note to authors describing the usage of an interface.</p>
+
+   </dd>
+
+  </dl>
+
+  <pre class="css">/* this is a CSS fragment */</pre>
+
+  <p>The defining instance of a term is marked up like <dfn data-x="x-this">this</dfn>. Uses of that
+  term are marked up like <span data-x="x-this">this</span> or like <i data-x="x-this">this</i>.</p>
+
+  <p>The defining instance of an element, attribute, or API is marked up like <dfn
+  data-x="x-that"><code>this</code></dfn>. References to that element, attribute, or API are marked
+  up like <code data-x="x-that">this</code>.</p>
+
+  <p>Other code fragments are marked up <code data-x="">like this</code>.</p>
+
+  <p>Variables are marked up like <var data-x="">this</var>.</p>
+
+  <p>In an algorithm, steps in <span data-x="synchronous section">synchronous sections</span> are
+  marked with &#x231B;.</p>
+
+  <p>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:</p>
+
+  <dl class="switch">
+
+   <dt>This is a condition
+   <dt>This is another condition
+   <dd>This is the requirement that applies to the conditions above.
+
+   <dt>This is a third condition
+   <dd>This is the requirement that applies to the third condition.
+
+  </dl>
+
+
+
+  <h3 id="fingerprint">Privacy concerns</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>Some features of HTML trade user convenience for a measure of user privacy.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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.)</p>
+
+  <p>Features in this specification which can be <dfn data-x="fingerprinting vector">used to
+  fingerprint the user</dfn> are marked as this paragraph is.
+  <!--INSERT FINGERPRINT-->
+  </p>
+
+  <p>Other features in the platform can be used for the same purpose, though, including, though not
+  limited to:</p>
+
+  <ul>
+
+   <li>The exact list of which features a user agents supports.</li>
+
+   <li>The maximum allowed stack depth for recursion in script.</li>
+
+   <li>Features that describe the user's environment, like Media Queries and the <code>Screen</code>
+   object. <a href="#refsMQ">[MQ]</a> <a href="#refsCSSOMVIEW">[CSSOMVIEW]</a></li>
+
+   <li>The user's time zone.</li>
+
+  </ul>
+
+
+
+  <h3>A quick introduction to HTML</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>A basic HTML document looks like this:</p>
+
+  <pre id="intro-early-example">&lt;!DOCTYPE html>
+&lt;html>
+ &lt;head>
+  &lt;title>Sample page&lt;/title>
+ &lt;/head>
+ &lt;body>
+  &lt;h1>Sample page&lt;/h1>
+  &lt;p>This is a &lt;a href="demo.html">simple&lt;/a> sample.&lt;/p>
+  &lt;!-- this is a comment -->
+ &lt;/body>
+&lt;/html></pre>
+
+  <p>HTML documents consist of a tree of elements and text. Each element is denoted in the source by
+  a <span data-x="syntax-start-tag">start tag</span>, such as "<code data-x="">&lt;body></code>", and
+  an <span data-x="syntax-end-tag">end tag</span>, such as "<code data-x="">&lt;/body></code>".
+  (Certain start tags and end tags can in certain cases be <span
+  data-x="syntax-tag-omission">omitted</span> and are implied by other tags.)</p>
+
+  <p>Tags have to be nested such that elements are all completely within each other, without
+  overlapping:</p>
+
+  <pre class="bad">&lt;p>This is &lt;em>very &lt;strong>wrong&lt;/em>!&lt;/strong>&lt;/p></pre>
+  <pre>&lt;p>This &lt;em>is &lt;strong>correct&lt;/strong>.&lt;/em>&lt;/p></pre>
+
+  <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.</p>
+
+  <p>Elements can have attributes, which control how the elements work. In the example below, there
+  is a <span>hyperlink</span>, formed using the <code>a</code> element and its <code
+  data-x="attr-hyperlink-href">href</code> attribute:</p>
+
+  <pre>&lt;a href="demo.html">simple&lt;/a></pre>
+
+  <p><span data-x="syntax-attributes">Attributes</span> are placed inside the start tag, and consist
+  of a <span data-x="syntax-attribute-name">name</span> and a <span
+  data-x="syntax-attribute-value">value</span>, separated by an "<code data-x="">=</code>" character.
+  The attribute value can remain <a href="#unquoted">unquoted</a> if it doesn't contain <span
+  data-x="space character">space characters</span> or any of <code data-x="">"</code> <code
+  data-x="">'</code> <code data-x="">`</code> <code data-x="">=</code> <code data-x="">&lt;</code> or
+  <code data-x="">&gt;</code>. Otherwise, it has to be quoted using either single or double quotes.
+  The value, along with the "<code data-x="">=</code>" character, can be omitted altogether if the
+  value is the empty string.</p>
+
+  <pre>&lt;!-- empty attributes -->
+&lt;input name=address disabled>
+&lt;input name=address disabled="">
+
+&lt;!-- attributes with a value -->
+&lt;input name=address maxlength=200>
+&lt;input name=address maxlength='200'>
+&lt;input name=address maxlength="200"></pre>
+
+  <p>HTML user agents (e.g. Web browsers) then <i>parse</i> this markup, turning it into a DOM
+  (Document Object Model) tree. A DOM tree is an in-memory representation of a document.</p>
+
+  <p>DOM trees contain several kinds of nodes, in particular a <code>DocumentType</code> node,
+  <code>Element</code> nodes, <code>Text</code> nodes, <code>Comment</code> nodes, and in some cases
+  <code>ProcessingInstruction</code> nodes.</p>
+
+  <p>The <a href="#intro-early-example">markup snippet at the top of this section</a> would be
+  turned into the following DOM tree:</p>
+
+  <ul class="domTree"><li class="t10">DOCTYPE: <code data-x="">html</code></li><li class="t1"><code>html</code><ul><li class="t1"><code>head</code><ul><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t1"><code>title</code><ul><li class="t3"><code>#text</code>: <span data-x="">Sample page</span></li></ul></li><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;</span></li></ul></li><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;</span></li><li class="t1"><code>body</code><ul><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t1"><code>h1</code><ul><li class="t3"><code>#text</code>: <span data-x="">Sample page</span></li></ul></li><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span data-x="">This is a <!--grammar-check-override--></span></li><li class="t1"><code>a</code> <span data-x="" class="t2"><code class="attribute name">href</code>="<code class="attribute value">demo.html</code>"</span><ul><li class="t3"><code>#text</code>: <span data-x="">simple</span></li></ul></li><li class="t3"><code>#text</code>: <span data-x=""> sample.</span></li></ul></li><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t8"><code>#comment</code>: <span data-x=""> this is a comment </span></li><li class="t3"><code>#text</code>: <span data-x="">&#x23CE;&#x2423;&#x23CE;</span></li></ul></li></ul></li></ul>
+
+  <p>The <span>root element</span> of this tree is the <code>html</code> element, which is the
+  element always found at the root of HTML documents. It contains two elements, <code>head</code>
+  and <code>body</code>, as well as a <code>Text</code> node between them.</p>
+
+  <p>There are many more <code>Text</code> nodes in the DOM tree than one would initially expect,
+  because the source contains a number of spaces (represented here by "&#x2423;") and line breaks
+  ("&#x23CE;") that all end up as <code>Text</code> 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 <code>head</code> start tag ends up being dropped silently,
+  and all the whitespace after the <code>body</code> end tag ends up placed at the end of the
+  <code>body</code>.</p>
+
+  <p>The <code>head</code> element contains a <code>title</code> element, which itself contains a
+  <code>Text</code> node with the text "Sample page". Similarly, the <code>body</code> element
+  contains an <code>h1</code> element, a <code>p</code> element, and a comment.</p>
+
+  <hr>
+
+  <p>This DOM tree can be manipulated from scripts in the page. Scripts (typically in JavaScript)
+  are small programs that can be embedded using the <code>script</code> element or using <span>event
+  handler content attributes</span>. For example, here is a form with a script that sets the value
+  of the form's <code>output</code> element to say "Hello World":</p>
+
+  <pre>&lt;<span>form</span> <span data-x="attr-form-name">name</span>="main">
+ Result: &lt;<span>output</span> <span data-x="attr-fe-name">name</span>="result">&lt;/output>
+ &lt;<span>script</span>>
+  <span data-x="Document">document</span>.<span data-x="dom-document-forms">forms</span>.main.<span data-x="dom-form-elements">elements</span>.result.<span data-x="dom-output-value">value</span> = 'Hello World';
+ &lt;/script>
+&lt;/form></pre>
+
+  <p>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 <code>a</code> element in the tree above)
+  can have its "<code data-x="attr-hyperlink-href">href</code>" attribute changed in several
+  ways:</p>
+
+  <pre>var a = <span data-x="Document">document</span>.<span data-x="dom-document-links">links</span>[0]; // obtain the first link in the document
+a.<span data-x="dom-url-href">href</span> = 'sample.html'; // change the destination URL of the link
+a.<span data-x="dom-url-protocol">protocol</span> = 'https'; // change just the scheme part of the URL
+a.setAttribute('href', 'http://example.com/'); // change the content attribute directly</pre>
+
+  <p>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.</p>
+
+  <hr>
+
+  <p>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.</p>
+
+  <p>In the following example, the page has been made yellow-on-blue using CSS.</p>
+
+  <pre>&lt;!DOCTYPE html>
+&lt;html>
+ &lt;head>
+  &lt;title>Sample styled page&lt;/title>
+  &lt;style>
+   body { background: navy; color: yellow; }
+  &lt;/style>
+ &lt;/head>
+ &lt;body>
+  &lt;h1>Sample styled page&lt;/h1>
+  &lt;p>This page is just a demo.&lt;/p>
+ &lt;/body>
+&lt;/html></pre>
+
+  <p>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.</p>
+
+
+
+<!--ADD-TOPIC:Security-->
+  <h4>Writing secure applications with HTML</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>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. <a
+  href="#refsORIGIN">[ORIGIN]</a></p>
+
+  <dl>
+
+   <dt>Not validating user input</dt>
+   <dt>Cross-site scripting (XSS)</dt>
+   <dt>SQL injection</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p>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).</p>
+
+    <div class="example">
+
+     <p>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:</p>
+
+     <pre>&lt;ul>
+ &lt;li>&lt;a href="message.cgi?say=Hello">Say Hello&lt;/a>
+ &lt;li>&lt;a href="message.cgi?say=Welcome">Say Welcome&lt;/a>
+ &lt;li>&lt;a href="message.cgi?say=Kittens">Say Kittens&lt;/a>
+&lt;/ul></pre>
+
+     <p>If the message was just displayed to the user without escaping, a hostile attacker could
+     then craft a URL that contained a script element:</p>
+
+     <pre>http://example.com/message.cgi?say=%3Cscript%3Ealert%28%27Oh%20no%21%27%29%3C/script%3E</pre>
+
+     <p>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.</p>
+
+     <p>This is called a cross-site scripting attack.</p>
+
+    </div>
+
+    <p>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:</p>
+
+    <ul>
+
+     <li>When allowing harmless-seeming elements like <code>img</code>, it is important to whitelist
+     any provided attributes as well. If one allowed all attributes then an attacker could, for
+     instance, use the <code data-x="handler-onload">onload</code> attribute to run arbitrary
+     script.</li>
+
+     <li>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 "<code data-x="javascript-protocol">javascript:</code>", but user agents can
+     implement (and indeed, have historically implemented) others.</li> <!-- IE had vbscript:,
+     Netscape had livescript:, etc. -->
+
+     <li>Allowing a <code>base</code> element to be inserted means any <code>script</code> elements
+     in the page with relative links can be hijacked, and similarly that any form submissions can
+     get redirected to a hostile site.</li>
+
+    </ul>
+
+   </dd>
+
+
+   <dt>Cross-site request forgery (CSRF)</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p>This problem exists because HTML forms can be submitted to other origins.</p>
+
+    <p>Sites can prevent such attacks by populating forms with user-specific hidden tokens, or by
+    checking <code data-x="http-origin">Origin</code> headers on all requests.</p>
+
+   </dd>
+
+
+
+   <dt>Clickjacking</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p>One way that a user could be so tricked is if a hostile site places the victim site in a
+    small <code>iframe</code> 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.</p>
+
+    <p>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 <code
+    data-x="dom-window">window</code> object to the value of the <code data-x="dom-top">top</code>
+    attribute).</p>
+
+   </dd>
+
+  </dl>
+<!--REMOVE-TOPIC:Security-->
+
+
+  <h4>Common pitfalls to avoid when using the scripting APIs</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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.</p>
+
+  <p>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.</p>
+
+  <p>There are two techniques for doing this reliably: use <span>event handler content
+  attributes</span>, 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.</p>
+
+  <div class="example">
+
+   <p>One way this could manifest itself is with <code>img</code> elements and the <code
+   data-x="event-load">load</code> event. The event could fire as soon as the element has been
+   parsed, especially if the image has already been cached (which is common).</p>
+
+   <p>Here, the author uses the <code data-x="handler-onload">onload</code> handler on an
+   <code>img</code> element to catch the <code data-x="event-load">load</code> event:</p>
+
+   <pre>&lt;img src="games.png" alt="Games" onload="gamesLogoHasLoaded(event)"></pre>
+
+   <p>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:</p>
+
+   <pre>&lt;script>
+ var img = new Image();
+ img.src = 'games.png';
+ img.alt = 'Games';
+ img.onload = gamesLogoHasLoaded;
+ // img.addEventListener('load', gamesLogoHasLoaded, false); // would work also
+&lt;/script></pre>
+
+   <p>However, if the author first created the <code>img</code> element and then in a separate
+   script added the event listeners, there's a chance that the <code data-x="event-load">load</code>
+   event would be fired in between, leading it to be missed:</p>
+
+   <pre class="bad">&lt;!-- Do not use this style, it has a race condition! -->
+ &lt;img id="games" src="games.png" alt="Games">
+ &lt;!-- the 'load' event might fire here while the parser is taking a
+      break, in which case you will not see it! -->
+ &lt;script>
+  var img = document.getElementById('games');
+  img.onload = gamesLogoHasLoaded; // might never fire!
+ &lt;/script></pre>
+
+  </div>
+
+
+
+  <h4>How to catch mistakes when writing HTML: validators and conformance checkers</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>Authors are encouraged to make use of conformance checkers (also known as <i>validators</i>) to
+  catch common mistakes. The WHATWG maintains a list of such tools at: <a
+  href="http://validator.whatwg.org/">http://validator.whatwg.org/</a></p>
+
+
+
+  <h3>Conformance requirements for authors</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>Unlike previous versions of the HTML specification, this specification defines in some detail
+  the required processing for invalid documents as well as valid documents.</p> <!-- This has led to
+  some questioning the purpose of conformance criteria: if there is no ambiguity in how something
+  will be processed, why disallow it? -->
+
+  <p>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.</p>
+
+
+  <h4>Presentational markup</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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:</p>
+
+  <dl>
+
+   <dt>The use of presentational elements leads to poorer accessibility</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p>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).</p>
+
+   </dd>
+
+
+   <dt>Higher cost of maintenance</dt>
+
+   <dd>
+
+    <p>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
+    <code>&lt;font&nbsp;color=""></code> 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.</p>
+
+   </dd>
+
+
+   <dt>Larger document sizes</dt>
+
+   <dd>
+
+    <p>Presentational markup tends to be much more redundant, and thus results in larger document
+    sizes.</p>
+
+   </dd>
+
+  </dl>
+
+  <p>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.</p>
+
+  <p>The only remaining presentational markup features in HTML are the <code
+  data-x="attr-style">style</code> attribute and the <code>style</code> element. Use of the <code
+  data-x="attr-style">style</code> 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 <code>style</code> 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.</p>
+
+  <p>It is also worth noting that some elements that were previously presentational have been
+  redefined in this specification to be media-independent: <code>b</code>, <code>i</code>,
+  <code>hr</code>, <code>s</code>, <code>small</code>, and <code>u</code>.</p>
+
+
+  <h4>Syntax errors</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>The syntax of HTML is constrained to avoid a wide variety of problems.</p>
+
+  <dl>
+
+   <dt>Unintuitive error-handling behavior</dt>
+
+   <dd>
+
+    <p>Certain invalid syntax constructs, when parsed, result in DOM trees that are highly
+    unintuitive.</p>
+
+    <div class="example">
+
+     <p>For example, the following markup fragment results in a DOM with an <code>hr</code> element
+     that is an <em>earlier</em> sibling of the corresponding <code>table</code> element:</p>
+
+     <pre class="bad">&lt;table>&lt;hr>...</pre>
+
+    </div>
+
+   </dd>
+
+
+   <dt>Errors with optional error recovery</dt>
+
+   <dd>
+
+    <p>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 <span>parse error</span>.</p>
+
+   </dd>
+
+
+   <dt>Errors where the error-handling behavior is not compatible with streaming user agents</dt>
+
+   <dd>
+
+    <p>Some error-handling behavior, such as the behavior for the <code
+    data-x="">&lt;table>&lt;hr>...</code> 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.</p>
+
+   </dd>
+
+
+   <dt>Errors that can result in infoset coercion</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+   </dd>
+
+
+   <dt>Errors that result in disproportionally poor performance</dt>
+
+   <dd>
+
+    <p>Certain syntax constructs can result in disproportionally poor performance. To discourage the
+    use of such constructs, they are typically made non-conforming.</p>
+
+    <div class="example">
+
+     <p>For example, the following markup results in poor performance, since all the unclosed
+     <code>i</code> elements have to be reconstructed in each paragraph, resulting in progressively
+     more elements in each paragraph:</p>
+
+     <pre class="bad">&lt;p>&lt;i>He dreamt.
+&lt;p>&lt;i>He dreamt that he ate breakfast.
+&lt;p>&lt;i>Then lunch.
+&lt;p>&lt;i>And finally dinner.</pre>
+
+     <p>The resulting DOM for this fragment would be:</p>
+
+     <ul class="domTree"><li class="t1"><code>p</code><ul><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span data-x="">He dreamt.</span></li></ul></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>i</code><ul><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span data-x="">He dreamt that he ate breakfast.</span></li></ul></li></ul></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>i</code><ul><li class="t1"><code>i</code><ul><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span data-x="">Then lunch.</span></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>i</code><ul><li class="t1"><code>i</code><ul><li class="t1"><code>i</code><ul><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span data-x="">And finally dinner.</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>
+
+    </div>
+
+   </dd>
+
+
+   <dt>Errors involving fragile syntax constructs</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <div class="example">
+
+     <p>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 <em>does</em> form a named character reference, they will be interpreted as that
+     character instead.</p>
+
+     <p>In this fragment, the attribute's value is "<code data-x="">?bill&amp;ted</code>":</p>
+
+     <pre class="bad">&lt;a href="?bill&amp;ted">Bill and Ted&lt;/a></pre>
+
+     <p>In the following fragment, however, the attribute's value is actually "<code
+     data-x="">?art&copy;</code>", <em>not</em> the intended "<code data-x="">?art&amp;copy</code>",
+     because even without the final semicolon, "<code data-x="">&amp;copy</code>" is handled the same
+     as "<code data-x="">&amp;copy;</code>" and thus gets interpreted as "<code
+     data-x="">&copy;</code>":</p>
+
+     <pre class="bad">&lt;a href="?art&amp;copy">Art and Copy&lt;/a></pre>
+
+     <p>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.</p>
+
+     <p>Thus, the correct way to express the above cases is as
+     follows:</p>
+
+     <pre>&lt;a href="?bill&amp;ted">Bill and Ted&lt;/a> &lt;!-- &amp;ted is ok, since it's not a named character reference --></pre>
+     <pre>&lt;a href="?art&amp;amp;copy">Art and Copy&lt;/a> &lt;!-- the &amp; has to be escaped, since &amp;copy <em>is</em> a named character reference --></pre>
+
+    </div>
+
+   </dd>
+
+
+   <dt>Errors involving known interoperability problems in legacy user agents</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <div class="example">
+
+     <p>For example, this is why the U+0060 GRAVE ACCENT character (`) is not allowed in unquoted
+     attributes. In certain legacy user agents, <!-- namely IE --> it is sometimes treated as a
+     quote character.</p>
+
+    </div>
+
+    <div class="example">
+
+     <p>Another example of this is the DOCTYPE, which is required to trigger <span>no-quirks
+     mode</span>, because the behavior of legacy user agents in <span>quirks mode</span> is often
+     largely undocumented.</p>
+
+    </div>
+
+   </dd>
+
+
+<!--ADD-TOPIC:Security-->
+   <dt>Errors that risk exposing authors to security attacks</dt>
+
+   <dd>
+
+    <p>Certain restrictions exist purely to avoid known security problems.</p>
+
+    <div class="example">
+
+     <p>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. <a href="#refsUTF7">[UTF7]</a></p>
+
+    </div>
+
+   </dd>
+<!--REMOVE-TOPIC:Security-->
+
+
+   <dt>Cases where the author's intent is unclear</dt>
+
+   <dd>
+
+    <p>Markup where the author's intent is very unclear is often made non-conforming. Correcting
+    these errors early makes later maintenance easier.</p>
+
+    <div class="example">
+
+     <p>For example, it is unclear whether the author intended the following to be an
+     <code>h1</code> heading or an <code>h2</code> heading:</p>
+
+     <pre class="bad">&lt;h1>Contact details&lt;/h2></pre>
+
+    </div>
+
+   </dd>
+
+
+   <dt>Cases that are likely to be typos</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <div class="example">
+
+     <p>For example, if the author typed <code>&lt;capton></code> instead of
+     <code>&lt;caption></code>, this would be flagged as an error and the author could correct the
+     typo immediately.</p>
+
+    </div>
+
+   </dd>
+
+
+   <dt>Errors that could interfere with new syntax in the future</dt>
+
+   <dd>
+
+    <p>In order to allow the language syntax to be extended in the future, certain otherwise
+    harmless features are disallowed.</p>
+
+    <div class="example">
+
+     <p>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.</p>
+
+    </div>
+
+   </dd>
+
+
+  </dl>
+
+  <p>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.</p>
+
+
+
+  <h4>Restrictions on content models and on attribute values</h4>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>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:</p>
+
+  <dl>
+
+
+   <dt>Errors involving content with dubious semantics</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="example">For example, this specification disallows nesting a <code>section</code>
+    element inside a <code>kbd</code> element, since it is highly unlikely for an author to indicate
+    that an entire section should be keyed in.</p>
+
+   </dd>
+
+
+   <dt>Errors that involve a conflict in expressed semantics</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <div class="example">
+
+     <p>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.</p>
+
+     <pre class="bad">&lt;hr role="cell"></pre>
+     <pre class="bad">&lt;input type=radio role=progressbar></pre>
+
+    </div>
+
+    <p class="example">Another example is the restrictions on the content models of the
+    <code>ul</code> element, which only allows <code>li</code> element children. Lists by definition
+    consist just of zero or more list items, so if a <code>ul</code> element contains something
+    other than an <code>li</code> element, it's not clear what was meant.</p>
+
+   </dd>
+
+
+   <dt>Cases where the default styles are likely to lead to confusion</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="example">For example, <code>div</code> elements are rendered as block boxes, and
+    <code>span</code> elements as inline boxes. Putting a block box in an inline box is
+    unnecessarily confusing; since either nesting just <code>div</code> elements, or nesting just
+    <code>span</code> elements, or nesting <code>span</code> elements inside <code>div</code>
+    elements all serve the same purpose as nesting a <code>div</code> element in a <code>span</code>
+    element, but only the latter involves a block box in an inline box, the latter combination is
+    disallowed.</p>
+
+    <p class="example">Another example would be the way <span>interactive content</span> cannot be
+    nested. For example, a <code>button</code> element cannot contain a <code>textarea</code>
+    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.</p>
+
+   </dd>
+
+
+   <dt>Errors that indicate a likely misunderstanding of the specification</dt>
+
+   <dd>
+
+    <p>Sometimes, something is disallowed because allowing it would likely cause author
+    confusion.</p>
+
+    <p class="example">For example, setting the <code data-x="attr-fe-disabled">disabled</code>
+    attribute to the value "<code data-x="">false</code>" is disallowed, because despite the
+    appearance of meaning that the element is enabled, it in fact means that the element is
+    <em>disabled</em> (what matters for implementations is the presence of the attribute, not its
+    value).</p>
+
+   </dd>
+
+
+   <dt>Errors involving limits that have been imposed merely to simplify the language</dt>
+
+   <dd>
+
+    <p>Some conformance errors simplify the language that authors need to learn.</p>
+
+    <p class="example">For example, the <code>area</code> element's <code
+    data-x="attr-area-shape">shape</code> attribute, despite accepting both <code
+    data-x="attr-area-shape-keyword-circ">circ</code> and <code
+    data-x="attr-area-shape-keyword-circle">circle</code> values in practice as synonyms, disallows
+    the use of the <code data-x="attr-area-shape-keyword-circ">circ</code> 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.</p>
+
+   </dd>
+
+
+   <dt>Errors that involve peculiarities of the parser</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <div class="example">
+
+     <p>For example, a <code>form</code> element isn't allowed inside <span>phrasing content</span>,
+     because when parsed as HTML, a <code>form</code> element's start tag will imply a
+     <code>p</code> element's end tag. Thus, the following markup results in two <span
+     data-x="paragraph">paragraphs</span>, not one:</p>
+
+     <pre>&lt;p>Welcome. &lt;form>&lt;label>Name:&lt;/label> &lt;input>&lt;/form></pre>
+
+     <p>It is parsed exactly like the following:</p>
+
+     <pre>&lt;p>Welcome. &lt;/p>&lt;form>&lt;label>Name:&lt;/label> &lt;input>&lt;/form></pre>
+
+    </div>
+
+   </dd>
+
+
+   <dt>Errors that would likely result in scripts failing in hard-to-debug ways</dt>
+
+   <dd>
+
+    <p>Some errors are intended to help prevent script problems that would be hard to debug.</p>
+
+    <p class="example">This is why, for instance, it is non-conforming to have two <code
+    data-x="attr-id">id</code> attributes with the same value. Duplicate IDs lead to the wrong
+    element being selected, with sometimes disastrous effects whose cause is hard to determine.</p>
+
+   </dd>
+
+
+   <dt>Errors that waste authoring time</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="example">For example, a <code>script</code> element's <code
+    data-x="attr-script-src">src</code> 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
+    &mdash; 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 <code>script</code> element when the <code
+    data-x="attr-script-src">src</code> attribute is present. This means that authors who are
+    validating their documents are less likely to waste time with this kind of mistake.</p>
+
+   </dd>
+
+
+   <dt>Errors that involve areas that affect authors migrating to and from XHTML</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="example">For example, there are somewhat complicated rules surrounding the <code
+    data-x="attr-lang">lang</code> and <code data-x="attr-xml-lang">xml:lang</code> attributes
+    intended to keep the two synchronized.</p>
+
+    <p class="example">Another example would be the restrictions on the values of <code
+    data-x="">xmlns</code> 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.</p>
+
+   </dd>
+
+
+   <dt>Errors that involve areas reserved for future expansion</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="example">For example, limiting the values of the <code
+    data-x="attr-hyperlink-target">target</code> 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.</p>
+
+   </dd>
+
+
+   <dt>Errors that indicate a mis-use of other specifications</dt>
+
+   <dd>
+
+    <p>Certain restrictions are intended to support the restrictions made by other
+    specifications.</p>
+
+    <p class="example">For example, requiring that attributes that take media queries use only
+    <em>valid</em> media queries reinforces the importance of following the conformance rules of
+    that specification.</p>
+
+   </dd>
+
+  </dl>
+
+
+
+  <h3>Suggested reading</h3>
+
+  <!-- NON-NORMATIVE SECTION -->
+
+  <p>The following documents might be of interest to readers of this specification.</p>
+
+  <dl>
+
+   <dt><cite>Character Model for the World Wide Web 1.0: Fundamentals</cite> <a href="#refsCHARMOD">[CHARMOD]</a></dt>
+
+   <dd><blockquote><p>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.</p></blockquote></dd>
+
+   <dt><cite>Unicode Security Considerations</cite> <a href="#refsUTR36">[UTR36]</a></dt>
+
+   <dd><blockquote><p>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.</p></blockquote></dd>
+
+   <dt><cite>Web Content Accessibility Guidelines (WCAG) 2.0</cite> <a href="#refsWCAG">[WCAG]</a></dt>
+
+   <dd><blockquote><p>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.</p></blockquote></dd>
+
+   <dt class="nodev"><cite>Authoring Tool Accessibility Guidelines (ATAG) 2.0</cite> <a href="#refsATAG">[ATAG]</a></dt>
+
+   <dd class="nodev"><blockquote><p>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.</p></blockquote></dd>
+
+   <dt class="nodev"><cite>User Agent Accessibility Guidelines (UAAG) 2.0</cite> <a href="#refsUAAG">[UAAG]</a></dt>
+
+   <dd class="nodev"><blockquote><p>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.</p></blockquote></dd>
+
+  </dl>
+
+
+
+  <h2 id="infrastructure">Common infrastructure</h2>
+
+  <h3>Terminology</h3>
+
+  <p>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 <dfn
+  data-x="">content attributes</dfn> for HTML and XML attributes, and <dfn data-x="">IDL
+  attributes</dfn> 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 <dfn data-x="">object properties</dfn> and <dfn data-x="">CSS properties</dfn> respectively.</p>
+
+  <p>Generally, when the specification states that a feature applies to <span>the HTML syntax</span>
+  or <span>the XHTML syntax</span>, 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)".</p>
+
+  <p>This specification uses the term <dfn data-x="">document</dfn> 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 <code>Document</code>
+  objects and their descendant DOM trees, and to serialised byte streams using the <span data-x="the
+  HTML syntax">HTML syntax</span> or <span data-x="the XHTML syntax">XHTML syntax</span>, depending
+  on context.</p>
+
+  <p>In the context of the DOM structures, the terms <span data-x="HTML documents">HTML
+  document</span> and <span data-x="XML documents">XML document</span> are used as defined in the DOM
+  specification, and refer specifically to two different modes that <code>Document</code> objects
+  can find themselves in. <a href="#refsDOM">[DOM]</a> (Such uses are always hyperlinked to their
+  definition.)</p>
+
+  <p>In the context of byte streams, the term HTML document refers to resources labeled as
+  <code>text/html</code>, and the term XML document refers to resources labeled with an <span>XML
+  MIME type</span>.</p>
+
+  <p>The term <dfn>XHTML document</dfn> is used to refer to both <code>Document</code>s in the <span
+  data-x="XML documents">XML document</span> mode that contains element nodes in the <span>HTML
+  namespace</span>, and byte streams labeled with an <span>XML MIME type</span> that contain
+  elements from the <span>HTML namespace</span>, depending on context.</p>
+
+  <hr>
+
+  <p>For simplicity, terms such as <dfn data-x="">shown</dfn>, <dfn data-x="">displayed</dfn>, and
+  <dfn data-x="">visible</dfn> 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.</p>
+
+  <div class="nodev">
+
+  <p>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.</p>
+
+  </div>
+
+  <!-- should find somewhere more appropriate to put this -->
+  <p>The term "transparent black" refers to the colour with red, green, blue, and alpha channels all
+  set to zero.</p>
+
+
+  <h4>Resources</h4>
+
+  <p>The specification uses the term <dfn data-x="">supported</dfn> 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 <i>supported</i> 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 <i>supported</i> can depend on what features of the resource's format are in use.</p>
+
+  <p class="example">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.</p>
+
+  <p class="example">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.</p>
+
+  <p>What some specifications, in particular the HTTP specification, refer to as a
+  <i>representation</i> is referred to in this specification as a <dfn data-x="">resource</dfn>. <a
+  href="#refsHTTP">[HTTP]</a></p>
+
+  <p>The term <dfn>MIME type</dfn> is used to refer to what is sometimes called an <i>Internet media
+  type</i> in protocol literature. The term <i>media type</i> in this specification is used to refer
+  to the type of media intended for presentation, as used by the CSS specifications. <a
+  href="#refsRFC2046">[RFC2046]</a> <a href="#refsMQ">[MQ]</a></p>
+
+  <p>A string is a <dfn>valid MIME type</dfn> if it matches the <code data-x="">media-type</code>
+  rule defined in section 3.7 "Media Types" of RFC 2616. In particular, a <span>valid MIME
+  type</span> may include MIME type parameters. <a href="#refsHTTP">[HTTP]</a></p>
+
+  <p>A string is a <dfn>valid MIME type with no parameters</dfn> if it matches the <code
+  data-x="">media-type</code> 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. <a href="#refsHTTP">[HTTP]</a></p>
+
+  <p>The term <dfn>HTML MIME type</dfn> is used to refer to the <span>MIME type</span>
+  <code>text/html</code>.</p>
+
+  <p>A resource's <dfn>critical subresources</dfn> 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.</p>
+
+  <p>The term <dfn data-x="data protocol"><code data-x="">data:</code> URL</dfn> refers to <span
+  data-x="URL">URLs</span> that use the <code data-x="">data:</code> scheme. <a
+  href="#refsRFC2397">[RFC2397]</a></p>
+
+
+  <h4>XML</h4>
+
+  <p id="html-namespace">To ease migration from HTML to XHTML, UAs conforming to this specification
+  will place elements in HTML in the <code>http://www.w3.org/1999/xhtml</code> namespace, at least
+  for the purposes of the DOM and CSS. The term "<dfn>HTML elements</dfn>", when used in this
+  specification, refers to any element in that namespace, and thus refers to both HTML and XHTML
+  elements.</p>
+
+  <p>Except where otherwise stated, all elements defined or mentioned in this specification are in
+  the <span>HTML namespace</span> ("<code>http://www.w3.org/1999/xhtml</code>"), and all attributes
+  defined or mentioned in this specification have no namespace.</p>
+
+  <p>The term <dfn>element type</dfn> is used to refer to the set of elements that have a given
+  local name and namespace. For example, <code>button</code> elements are elements with the element
+  type <code>button</code>, meaning they have the local name "<code data-x="">button</code>" and
+  (implicitly as defined above) the <span>HTML namespace</span>.</p>
+
+  <p>Attribute names are said to be <dfn>XML-compatible</dfn> if they match the <a
+  href="http://www.w3.org/TR/xml/#NT-Name"><code data-x="">Name</code></a> production defined in XML
+  and they contain no U+003A COLON characters (:). <a href="#refsXML">[XML]</a></p>
+
+  <p>The term <dfn>XML MIME type</dfn> is used to refer to the <span data-x="MIME type">MIME
+  types</span> <code data-x="">text/xml</code>, <code data-x="">application/xml</code>, and any
+  <span>MIME type</span> whose subtype ends with the four characters "<code data-x="">+xml</code>".
+  <a href="#refsRFC3023">[RFC3023]</a></p>
+
+
+  <h4>DOM trees</h4>
+
+  <p>The <dfn>root element of a <code>Document</code> object</dfn> is that <code>Document</code>'s
+  first element child, if any. If it does not have one then the <code>Document</code> has no root
+  element.</p>
+
+  <p>The term <dfn>root element</dfn>, when not referring to a <code>Document</code> 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 <span>root
+  element</span> 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.</p>
+
+  <p>When an element's <span>root element</span> is the <span>root element of a
+  <code>Document</code> object</span>, it is said to be <dfn>in a <code>Document</code></dfn>. An
+  element is said to have been <dfn data-x="insert an element into a document">inserted into a
+  document</dfn> when its <span>root element</span> changes and is now the document's <span>root
+  element</span>. Analogously, an element is said to have been <dfn data-x="remove an element from a
+  document">removed from a document</dfn> when its <span>root element</span> changes from being the
+  document's <span>root element</span> to being another element.</p>
+
+  <p>A node's <dfn>home subtree</dfn> is the subtree rooted at that node's <span>root
+  element</span>. When a node is <span>in a <code>Document</code></span>, its <span>home
+  subtree</span> is that <code>Document</code>'s tree.</p>
+
+  <p>The <code>Document</code> of a <code>Node</code> (such as an element) is the
+  <code>Document</code> that the <code>Node</code>'s <code
+  data-x="dom-Node-ownerDocument">ownerDocument</code> IDL attribute returns. When a
+  <code>Node</code> is <span>in a <code>Document</code></span> then that <code>Document</code> is
+  always the <code>Node</code>'s <code>Document</code>, and the <code>Node</code>'s <code
+  data-x="dom-Node-ownerDocument">ownerDocument</code> IDL attribute thus always returns that
+  <code>Document</code>.</p>
+
+  <p>The <code>Document</code> of a content attribute is the <code>Document</code> of the
+  attribute's element.</p>
+
+  <p>The term <dfn>tree order</dfn> means a pre-order, depth-first traversal of DOM nodes involved
+  (through the <code data-x="dom-Node-parentNode">parentNode</code>/<code
+  data-x="dom-Node-childNodes">childNodes</code> relationship).</p>
+
+  <p>When it is stated that some element or attribute is <dfn data-x="ignore">ignored</dfn>, 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. <span class="nodev">A user agent must not mutate the
+  DOM in such situations.</span></p>
+
+  <p>A content attribute is said to <dfn data-x="">change</dfn> 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.</p>
+
+  <p>The term <dfn data-x="">empty</dfn>, when used of an attribute value, <code>Text</code> node, or
+  string, means that the length of the text is zero (i.e. not even containing spaces or <span>control
+  characters</span>).</p>
+
+
+  <h4>Scripting</h4>
+
+  <p>The construction "a <code>Foo</code> object", where <code>Foo</code> is actually an interface,
+  is sometimes used instead of the more accurate "an object implementing the interface
+  <code>Foo</code>".</p>
+
+  <p>An IDL attribute is said to be <dfn data-x="">getting</dfn> when its value is being retrieved
+  (e.g. by author script), and is said to be <dfn data-x="">setting</dfn> when a new value is
+  assigned to it.</p>
+
+  <p>If a DOM object is said to be <dfn>live</dfn>, then the attributes and methods on that object
+  <span class="nodev">must</span> operate on the actual underlying data, not a snapshot of the
+  data.</p>
+
+  <p>In the contexts of events, the terms <i>fire</i> and <i>dispatch</i> are used as defined in the
+  DOM specification: <dfn data-x="concept-event-fire">firing</dfn> an event means to create and <span
+  data-x="concept-event-dispatch">dispatch</span> it, and <dfn
+  data-x="concept-event-dispatch">dispatching</dfn> an event means to follow the steps that propagate
+  the event through the tree. The term <dfn data-x="concept-events-trusted">trusted event</dfn> is
+  used to refer to events whose <code data-x="dom-event-isTrusted">isTrusted</code> attribute is
+  initialised to true. <a href="#refsDOM">[DOM]</a></p>
+
+
+  <h4>Plugins</h4>
+
+  <p>The term <dfn>plugin</dfn> 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 <code>Document</code> object, but
+  that neither act as <span data-x="child browsing context">child browsing contexts</span> of the
+  <code>Document</code> nor introduce any <code>Node</code> objects to the <code>Document</code>'s
+  DOM.</p>
+
+  <p>Typically such content handlers are provided by third parties, though a user agent can also
+  designate built-in content handlers as plugins.</p>
+
+  <div class="nodev">
+
+  <p>A user agent must not consider the types <code>text/plain</code> and
+  <code>application/octet-stream</code> as having a registered <span>plugin</span>.</p> <!-- because
+  of the way <object> elements handles those types, if nothing else (it also doesn't make any sense
+  to have a plugin registered for those types, of course) -->
+
+  </div>
+
+  <p class="example">One example of a plugin would be a PDF viewer that is instantiated in a
+  <span>browsing context</span> 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.</p>
+
+  <p class="note">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. <a href="#refsNPAPI">[NPAPI]</a></p>
+
+  <p>A plugin can be <dfn data-x="concept-plugin-secure">secured</dfn> if it honors the semantics of
+  the <code data-x="attr-iframe-sandbox">sandbox</code> attribute.</p>
+
+  <p class="example">For example, a secured plugin would prevent its contents from creating pop-up
+  windows when the plugin is instantiated inside a sandboxed <code>iframe</code>.</p>
+
+  <div class="nodev">
+
+  <p class="warning">Browsers should take extreme care when interacting with external content
+  intended for <span data-x="plugin">plugins</span>. 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.</p>
+
+  <p>Since different users having differents sets of <span data-x="plugin">plugins</span> provides a
+  fingerprinting vector that increases the chances of users being uniquely identified, user agents
+  are encouraged to support the exact same set of <span data-x="plugin">plugins</span> for each
+  user.
+  <!--INSERT FINGERPRINT-->
+  </p>
+
+  </div>
+
+
+
+  <h4 id="encoding-terminology">Character encodings</h4>
+
+  <p>A <dfn data-x="encoding">character encoding</dfn>, or just <i>encoding</i> 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 <span>encoding</span> has an <dfn>encoding name</dfn> and one or more
+  <dfn data-x="encoding label">encoding labels</dfn>, referred to as the encoding's <i>name</i> and
+  <i>labels</i> in the Encoding standard. <a href="#refsENCODING">[ENCODING]</a></p>
+
+  <p>An <dfn>ASCII-compatible character encoding</dfn> is a single-byte or variable-length
+  <span>encoding</span> in which the bytes 0x09, 0x0A, 0x0C, 0x0D, 0x20 - 0x22, 0x26, 0x27, 0x2C -
+  0x3F, 0x41 - 0x5A, and 0x61 - 0x7A<!-- is that list ok? do any character sets we want to support
+  do things outside that range? -->, 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<!--ANSI_X3.4-1968 (US-ASCII)-->. <a href="#refsENCODING">[ENCODING]</a></p>
+
+  <p class="note">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.</p>
+
+  <!--
+   We'll have to change that if anyone comes up with a way to have a document that is valid as two
+   different encodings at once, with different <meta charset> elements applying in each case.
+  -->
+
+  <p>The term <dfn>a UTF-16 encoding</dfn> refers to any variant of UTF-16: UTF-16LE or UTF-16BE,
+  regardless of the presence or absence of a BOM. <a href="#refsENCODING">[ENCODING]</a></p>
+
+  <p>The term <dfn>code unit</dfn> is used as defined in the Web IDL specification: a 16 bit
+  unsigned integer, the smallest atomic component of a <code>DOMString</code>. (This is a narrower
+  definition than the one used in Unicode, and is not the same as a <i>code point</i>.) <a
+  href="#refsWEBIDL">[WEBIDL]</a></p>
+
+  <p>The term <dfn>Unicode code point</dfn> means a <i data-x="">Unicode scalar value</i> 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 <span data-x="code unit">code units</span>
+  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. <a href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p>In this specification, the term <dfn>character</dfn>, when not qualified as <em>Unicode</em>
+  character, is synonymous with the term <span>Unicode code point</span>.</p>
+
+  <p>The term <dfn>Unicode character</dfn> is used to mean a <i data-x="">Unicode scalar value</i>
+  (i.e. any Unicode code point that is not a surrogate code point). <a
+  href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p>The <dfn>code-unit length</dfn> of a string is the number of <span data-x="code unit">code
+  units</span> in that string.</p>
+
+  <p class="note">This complexity results from the historical decision to define the DOM API in
+  terms of 16 bit (UTF-16) <span data-x="code unit">code units</span>, rather than in terms of <span
+  data-x="Unicode character">Unicode characters</span>.</p>
+
+
+
+  <div class="nodev">
+
+  <h3>Conformance requirements</h3>
+
+  <p>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.</p>
+
+  <p>The key words "MUST", "MUST NOT", <!--"REQUIRED",--> <!--"SHALL", "SHALL NOT",--> "SHOULD", "SHOULD
+  NOT", <!--"RECOMMENDED", "NOT RECOMMENDED",--> "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. <a href="#refsRFC2119">[RFC2119]</a></p>
+
+  <p>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.</p>
+
+  <div class="example">
+
+   <p>For example, were the spec to say:</p>
+
+   <pre>To eat an orange, the user must:
+1. Peel the orange.
+2. Separate each slice of the orange.
+3. Eat the orange slices.</pre>
+
+   <p>...it would be equivalent to the following:</p>
+
+   <pre>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.</pre>
+
+   <p>Here the key word is "must".</p>
+
+   <p>The former (imperative) style is generally preferred in this specification for stylistic
+   reasons.</p>
+
+  </div>
+
+  <p>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.)</p>
+
+  </div>
+
+
+
+  <div class="nodev">
+
+  <h4>Conformance classes</h4>
+
+  <p>This specification describes the conformance criteria for <span class="nodev">user agents
+  (relevant to implementors) and</span> documents<span class="nodev"> (relevant to authors and
+  authoring tool implementors)</span>.</p>
+
+  <p><dfn>Conforming documents</dfn> 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 &mdash; such user agents are subject to additional rules, as explained
+  below.)</p>
+
+  <p class="example">For example, if a requirement states that "authors must not use the <code
+  data-x="">foobar</code> element", it would imply that documents are not allowed to contain elements
+  named <code data-x="">foobar</code>.</p>
+
+  <p class="note impl">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.</p>
+
+  <p>User agents fall into several (overlapping) categories with different conformance
+  requirements.</p>
+
+  <dl>
+
+   <dt id="interactive">Web browsers and other interactive user agents</dt>
+
+   <dd>
+
+    <p>Web browsers that support <span>the XHTML syntax</span> must process elements and attributes
+    from the <span>HTML namespace</span> 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.</p>
+
+    <p class="example">A conforming XHTML processor would, upon finding an XHTML <code>script</code>
+    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 <code>script</code> element as an
+    opaque element that forms part of the transform.</p>
+
+    <p>Web browsers that support <span>the HTML syntax</span> must process documents labeled with an
+    <span>HTML MIME type</span> as described in this specification, so that users can interact with
+    them.</p>
+
+    <p>User agents that support scripting must also be conforming implementations of the IDL
+    fragments in this specification, as described in the Web IDL specification. <a
+    href="#refsWEBIDL">[WEBIDL]</a></p>
+
+    <p class="note">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 <code>script</code> element in the example above would still implement the
+    <code>HTMLScriptElement</code> interface.</p>
+
+   </dd>
+
+   <dt id="non-interactive">Non-interactive presentation user agents</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="note">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 <a href="#non-scripted">lack scripting
+    support</a>.</p>
+
+    <p class="example">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.</p>
+
+   </dd>
+
+   <dt id="renderingUA">Visual user agents that support the suggested default rendering</dt>
+
+   <dd>
+
+    <p>User agents, whether interactive or not, may be designated (possibly as a user option) as
+    supporting the suggested default rendering defined by this specification.</p>
+
+    <p>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.</p>
+
+    <p>User agents that are designated as supporting the suggested default rendering must, while so
+    designated, implement the rules in <a href="#rendering">the rendering section</a> that that
+    section defines as the behavior that user agents are <em>expected</em> to implement.</p>
+
+   </dd>
+
+   <dt id="non-scripted">User agents with no scripting support</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p class="note">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.</p>
+
+   </dd>
+
+
+   <dt>Conformance checkers</dt>
+
+   <dd id="conformance-checkers">
+
+    <p>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 <code>blockquote</code> element is not a quote,
+    conformance checkers running without the input of human judgement do not have to check that
+    <code>blockquote</code> elements only contain quoted material).</p>
+
+    <p>Conformance checkers must check that the input document conforms when parsed without a
+    <span>browsing context</span> (meaning that no scripts are run, and that the parser's
+    <span>scripting flag</span> is disabled), and should also check that the input document conforms
+    when parsed with a <span>browsing context</span> 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. <a href="#refsCOMPUTABLE">[COMPUTABLE]</a>)</p>
+
+    <p>The term "HTML validator" can be used to refer to a conformance checker that itself conforms
+    to the applicable requirements of this specification.</p>
+
+    <div class="note">
+
+     <p>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.</p>
+
+     <p>To put it another way, there are three types of conformance criteria:</p>
+
+     <ol>
+
+      <li>Criteria that can be expressed in a DTD.</li>
+
+      <li>Criteria that cannot be expressed by a DTD, but can still be checked by a machine.</li>
+
+      <li>Criteria that can only be checked by a human.</li>
+
+     </ol>
+
+     <p>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.</p>
+
+    </div>
+   </dd>
+
+
+   <dt>Data mining tools</dt>
+
+   <dd id="data-mining">
+
+    <p>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.</p>
+
+    <p class="example">A tool that generates <span data-x="outline">document outlines</span> but
+    increases the nesting level for each paragraph and does not increase the nesting level for each
+    section would not be conforming.</p>
+
+   </dd>
+
+
+   <dt id="editors">Authoring tools and markup generators</dt>
+
+   <dd>
+
+    <p>Authoring tools and markup generators must generate <span>conforming documents</span>.
+    Conformance criteria that apply to authors also apply to authoring tools, where appropriate.</p>
+
+    <p>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.</p>
+
+    <p class="example">For example, it is not conforming to use an <code>address</code> 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 <code>address</code> 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.</p>
+
+    <p class="note">In terms of conformance checking, an editor has to output documents that conform
+    to the same extent that a conformance checker will verify.</p>
+
+    <p>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.</p>
+
+    <p>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).</p>
+
+    <p>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.</p>
+
+    <p>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
+    <code>div</code>, <code>b</code>, <code>i</code>, and <code>span</code> and making liberal use
+    of the <code data-x="attr-style">style</code> attribute.</p>
+
+    <p>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.</p>
+
+   </dd>
+
+  </dl>
+
+  <p id="hardwareLimitations">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.
+  <!--INSERT FINGERPRINT-->
+  </p>
+
+  <p>For compatibility with existing content and prior specifications, this specification describes
+  two authoring formats: one based on XML (referred to as <span>the XHTML syntax</span>), and one
+  using a <a href="#writing">custom format</a> inspired by SGML (referred to as <span>the HTML
+  syntax</span>). Implementations must support at least one of these two formats, although
+  supporting both is encouraged.</p>
+
+  <p>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.)</p>
+
+  </div>
+
+
+  <div class="nodev">
+
+  <h4>Dependencies</h4>
+
+  <p>This specification relies on several other underlying specifications.</p>
+
+  <dl>
+
+   <dt>Unicode and Encoding</dt>
+
+   <dd>
+
+    <p>The Unicode character set is used to represent textual data, and the WHATWG Encoding standard
+    defines requirements around <span data-x="encoding">character encodings</span>. <a
+    href="#refsUNICODE">[UNICODE]</a></p>
+
+    <p class="note">This specification <a href="#encoding-terminology">introduces terminology</a>
+    based on the terms defined in those specifications, as described earlier.</p>
+
+    <p>The following terms are used as defined in the WHATWG Encoding standard: <a
+    href="#refsENCODING">[ENCODING]</a></p>
+
+    <ul class="brief">
+
+     <li><dfn>Getting an encoding</dfn>
+
+     <li>The <dfn>encoder</dfn> and <dfn>decoder</dfn> algorithms for various encodings, including
+     the <dfn>UTF-8 encoder</dfn> and <dfn>UTF-8 decoder</dfn>
+
+     <li>The generic <dfn>decode</dfn> algorithm which takes a byte stream and an encoding and
+     returns a character stream
+
+     <li>The <dfn>UTF-8 decode</dfn> algorithm which takes a byte stream and returns a character
+     stream, additionally stripping one leading UTF-8 Byte Order Mark (BOM), if any
+
+    </ul>
+
+    <p class="note">The <span>UTF-8 decoder</span> is distinct from the <i>UTF-8 decode
+    algorithm</i>. The latter first strips a Byte Order Mark (BOM), if any, and then invokes the
+    former.</p>
+
+    <p>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".)</p>
+
+   </dd>
+
+
+   <dt>XML</dt>
+
+   <dd>
+
+    <p>Implementations that support <span>the XHTML syntax</span> must support some version of XML,
+    as well as its corresponding namespaces specification, because that syntax uses an XML
+    serialisation with namespaces. <a href="#refsXML">[XML]</a> <a href="#refsXMLNS">[XMLNS]</a></p>
+
+   </dd>
+
+
+   <dt>URLs</dt>
+
+   <dd>
+
+    <p>The following terms are defined in the WHATWG URL standard: <a href="#refsURL">[URL]</a></p>
+
+    <ul class="brief">
+     <li><dfn>URL</dfn>
+     <li><dfn>Absolute URL</dfn>
+     <li><dfn>Relative URL</dfn>
+     <li><dfn data-x="concept-url-scheme-relative">Relative schemes</dfn>
+     <li>The <dfn>URL parser</dfn>
+     <li><dfn>Parsed URL</dfn>
+     <li>The <dfn data-x="concept-url-scheme">scheme</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-scheme-data">scheme data</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-username">username</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-password">password</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-host">host</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-port">port</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-path">path</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-query">query</dfn> component of a <span>parsed URL</span>
+     <li>The <dfn data-x="concept-url-fragment">fragment</dfn> component of a <span>parsed URL</span>
+     <li><dfn data-x="concept-url-parse-error">Parse errors</dfn> from the <span>URL parser</span>
+     <li>The <dfn data-x="concept-url-serializer">URL serializer</dfn>
+     <li><dfn>Default encode set</dfn>
+     <li><dfn>Percent encode</dfn>
+     <li><dfn>UTF-8 percent encode</dfn>
+     <li><dfn>Percent decode</dfn>
+     <li><dfn>Decoder error</dfn>
+     <li>The <dfn>domain label to ASCII</dfn> algorithm</li>
+     <li>The <dfn>domain label to Unicode</dfn> algorithm</li>
+     <li><dfn><code>URLUtils</code></dfn> interface
+     <li><dfn><code>URLUtilsReadOnly</code></dfn> interface
+     <li><dfn data-x="dom-url-href"><code>href</code> attribute</dfn>
+     <li><dfn data-x="dom-url-protocol"><code>protocol</code> attribute</dfn>
+     <li>The <dfn data-x="concept-uu-get-the-base">get the base</dfn> hook for <code>URLUtils</code>
+     <li>The <dfn data-x="concept-uu-update">update steps</dfn> hook for <code>URLUtils</code>
+     <li>The <dfn data-x="concept-uu-set-the-input">set the input</dfn> algorithm for <code>URLUtils</code>
+     <li>The <dfn data-x="concept-uu-query-encoding">query encoding</dfn> of an <code>URLUtils</code> object
+     <li>The <dfn data-x="concept-uu-input">input</dfn> of an <code>URLUtils</code> object
+     <li>The <dfn data-x="concept-uu-url">url</dfn> of an <code>URLUtils</code> object
+    </ul>
+
+   </dd>
+
+
+   <dt>Cookies</dt>
+
+   <dd>
+
+    <p>The following terms are defined in the Cookie specification: <a
+    href="#refsCOOKIES">[COOKIES]</a></p>
+
+    <ul class="brief">
+     <li><dfn>cookie-string</dfn>
+     <li><dfn>receives a set-cookie-string</dfn>
+    </ul>
+
+   </dd>
+
+
+   <dt>Fetch</dt>
+
+   <dd>
+
+    <p>The following terms are defined in the WHATWG Fetch specification: <a href="#refsFETCH">[FETCH]</a></p>
+
+    <ul class="brief">
+     <li><dfn>cross-origin request</dfn>
+     <li><dfn>cross-origin request status</dfn>
+     <li><dfn>custom request headers</dfn>
+     <li><dfn>simple cross-origin request</dfn>
+     <li><dfn>redirect steps</dfn>
+     <li><dfn>omit credentials flag</dfn>
+     <li><dfn>resource sharing check</dfn>
+    </ul>
+
+    <p class="note">This specification does not yet use the "fetch" algorithm from the WHATWG Fetch
+    specification. It will be updated to do so in due course.</p>
+
+   </dd>
+
+
+<!--TOPIC:DOM APIs-->
+
+   <dt>Web IDL</dt>
+
+   <dd>
+
+    <p>The IDL fragments in this specification must be interpreted as required for conforming IDL
+    fragments, as described in the Web IDL specification. <a href="#refsWEBIDL">[WEBIDL]</a></p>
+
+    <p>The terms <dfn>supported property indices</dfn>, <dfn>determine the value of an indexed
+    property</dfn>, <dfn>support named properties</dfn>, <dfn>supported property names</dfn>,
+    <dfn>unenumerable</dfn>, <dfn>determine the value of a named property</dfn>, <dfn>platform array
+    objects</dfn>, and <dfn data-x="dfn-read-only-array">read only</dfn> (when applied to arrays)
+    are used as defined in the Web IDL specification. The algorithm to <dfn>convert a DOMString to a
+    sequence of Unicode characters</dfn> is similarly that defined in the Web IDL specification.</p>
+
+    <p>When this specification requires a user agent to <dfn>create a <code>Date</code> object</dfn>
+    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 <code>Date</code> object must represent the resulting truncated time.</p>
+
+    <p class="example">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 <code>Date</code> 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 <code>Date</code> object that represents a time value NaN (indicating that the object does
+    not represent a specific instant of time).</p>
+
+   </dd>
+
+
+   <dt>JavaScript</dt>
+
+   <dd>
+
+    <p>Some parts of the language described by this specification only support JavaScript as the
+    underlying scripting language. <a href="#refsECMA262">[ECMA262]</a></p>
+
+    <p class="note">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 <span>MIME
+    type</span> used to refer to JavaScript in this specification is <code
+    data-x="">text/javascript</code>, since that is the most commonly used type, <span data-x="willful
+    violation">despite it being an officially obsoleted type</span> according to RFC 4329. <a
+    href="#refsRFC4329">[RFC4329]</a></p>
+
+    <p>The term <dfn>JavaScript global environment</dfn> refers to the <i data-x="">global
+    environment</i> concept defined in the ECMAScript specification.</p>
+
+    <p>The ECMAScript <dfn data-x="js-SyntaxError"><code>SyntaxError</code></dfn> exception is also
+    defined in the ECMAScript specification. <a href="#refsECMA262">[ECMA262]</a></p>
+
+    <p>The <dfn>ArrayBuffer</dfn> and related object types and underlying concepts from the
+    ECMAScript Specification are used for several features in this specification. <a
+    href="#refsECMA262">[ECMA262]</a></p>
+
+    <p>The following helper IDL is used for referring to <code>ArrayBuffer</code>-related types:</p>
+
+    <pre class="idl">typedef (<dfn>Int8Array</dfn> or <dfn>Uint8Array</dfn> or <dfn>Uint8ClampedArray</dfn> or
+         <dfn>Int16Array</dfn> or <dfn>Uint16Array</dfn> or
+         <dfn>Int32Array</dfn> or <dfn>Uint32Array</dfn> or
+         <dfn>Float32Array</dfn> or <dfn>Float64Array</dfn> or
+         <dfn>DataView</dfn>) <dfn>ArrayBufferView</dfn>;</pre>
+
+    <p class="note">In particular, the <code>Uint8ClampedArray</code> type is used by some <span
+    data-x="ImageData">2D canvas APIs</span>, and the <a href="#network"><code>WebSocket</code>
+    API</a> uses <code>ArrayBuffer</code> objects for handling binary frames.</p>
+
+   </dd>
+
+
+   <dt>DOM</dt>
+
+   <dd>
+
+    <p>The Document Object Model (DOM) is a representation &mdash; a model &mdash; 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. <a
+    href="#refsDOM">[DOM]</a></p>
+
+    <p>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. <a href="#refsDOM">[DOM]</a> <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
+
+    <p>In particular, the following features are defined in the DOM specification: <a
+    href="#refsDOM">[DOM]</a></p> <!-- aka DOM Core or DOMCORE -->
+
+    <ul class="brief">
+
+     <li><dfn><code>Attr</code></dfn> interface</li>
+     <li><dfn><code>Comment</code></dfn> interface</li>
+     <li><dfn><code>DOMImplementation</code></dfn> interface</li>
+     <li><dfn data-x="DOM Document"><code>Document</code></dfn> interface</li>
+     <li><dfn><code>XMLDocument</code></dfn> interface</li>
+     <li><dfn><code>DocumentFragment</code></dfn> interface</li>
+     <li><dfn><code>DocumentType</code></dfn> interface</li>
+     <li><dfn><code>DOMException</code></dfn> interface</li>
+     <li><dfn><code>ChildNode</code></dfn> interface</li>
+     <li><dfn><code>Element</code></dfn> interface</li>
+     <li><dfn><code>Node</code></dfn> interface</li>
+     <li><dfn><code>NodeList</code></dfn> interface</li>
+     <li><dfn><code>ProcessingInstruction</code></dfn> interface</li>
+     <li><dfn><code>Text</code></dfn> interface</li>
+
+     <li><dfn><code>HTMLCollection</code></dfn> interface</li>
+     <li><dfn data-x="dom-HTMLCollection-item"><code>item()</code></dfn> method</li>
+     <li>The terms <dfn>collections</dfn> and <dfn>represented by the collection</dfn></li>
+
+     <li><dfn><code>DOMTokenList</code></dfn> interface</li>
+     <li><dfn><code>DOMSettableTokenList</code></dfn> interface</li>
+
+     <li><dfn data-x="dom-DOMImplementation-createDocument"><code>createDocument()</code></dfn> method</li>
+     <li><dfn data-x="dom-DOMImplementation-createHTMLDocument"><code>createHTMLDocument()</code></dfn> method</li>
+     <li><dfn data-x="dom-Document-createElement"><code>createElement()</code></dfn> method</li>
+     <li><dfn data-x="dom-Document-createElementNS"><code>createElementNS()</code></dfn> method</li>
+     <li><dfn data-x="dom-Document-getElementById"><code>getElementById()</code></dfn> method</li>
+     <li><dfn data-x="dom-Node-insertBefore"><code>insertBefore()</code></dfn> method</li>
+
+     <li><dfn data-x="dom-Node-ownerDocument"><code>ownerDocument</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Node-childNodes"><code>childNodes</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Node-localName"><code>localName</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Node-parentNode"><code>parentNode</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Node-namespaceURI"><code>namespaceURI</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Element-tagName"><code>tagName</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Element-id"><code>id</code></dfn> attribute</li>
+     <li><dfn><code>textContent</code></dfn> attribute</li>
+
+     <li>The <dfn data-x="concept-node-insert">insert</dfn>, <dfn data-x="concept-node-append">append</dfn>, <dfn data-x="concept-node-remove">remove</dfn>, <dfn data-x="concept-node-replace">replace</dfn>, and <dfn data-x="concept-node-adopt">adopt</dfn> algorithms for nodes</li>
+     <li>The <dfn>nodes are inserted</dfn> and <dfn>nodes are removed</dfn> concepts</li>
+     <li>An element's <dfn data-x="concept-node-adopt-ext">adopting steps</dfn></li>
+     <li>The <dfn>attribute list</dfn> concept.</li>
+     <li>The <dfn data-x="concept-cd-data">data</dfn> of a text node.</li>
+
+     <li><dfn><code>Event</code></dfn> interface</li>
+     <li><dfn><code>EventTarget</code></dfn> interface</li>
+     <li><dfn><code>EventInit</code></dfn> dictionary type</li>
+     <li><dfn data-x="dom-Event-target"><code>target</code></dfn> attribute</li>
+     <li><dfn data-x="dom-Event-isTrusted"><code>isTrusted</code></dfn> attribute</li>
+     <li>The <dfn data-x="concept-event-type">type</dfn> of an event</li>
+     <li>The concept of an <dfn data-x=concept-event-listener>event listener</dfn> and the <span data-x=concept-event-listener>event listeners</span> associated with an <code>EventTarget</code></li>
+     <li>The concept of a <dfn>target override</dfn></li>
+     <li>The concept of a regular <dfn>event parent</dfn> and a <dfn>cross-boundary event parent</dfn></li> <!-- see bug 18780 -->
+
+     <li>The <dfn data-x="document's character encoding">encoding</dfn> (herein the <i>character encoding</i>) and <dfn data-x="concept-document-content-type">content type</dfn> of a <code>Document</code></li>
+     <li>The distinction between <dfn>XML documents</dfn> and <dfn>HTML documents</dfn></li>
+     <li>The terms <dfn>quirks mode</dfn>, <dfn>limited-quirks mode</dfn>, and <dfn>no-quirks mode</dfn></li>
+     <li>The algorithm to <dfn data-x="concept-node-clone">clone</dfn> a <code>Node</code>, and the concept of <dfn data-x="concept-node-clone-ext">cloning steps</dfn> used by that algorithm</li>
+     <li>The concept of <dfn>base URL change steps</dfn> and the definition of what happens when an element is <dfn>affected by a base URL change</dfn></li>
+     <li>The concept of an element's <dfn data-x="concept-id">unique identifier (ID)</dfn></li>
+
+     <li>The concept of a DOM <dfn data-x="concept-range">range</dfn>, and the terms <dfn data-x="concept-range-start">start</dfn>, <dfn data-x="concept-range-end">end</dfn>, and <dfn data-x="concept-range-bp">boundary point</dfn> as applied to ranges.</li>
+
+     <li><dfn><code>MutationObserver</code></dfn> interface</li>
+     <li>The <dfn data-x="concept-mo-invoke">invoke <code>MutationObserver</code> objects</dfn> algorithm</li>
+
+     <li><dfn>Promise</dfn> interface</li>
+     <li>The <dfn data-x="concept-resolver">resolver</dfn> concept</li>
+     <li>The <dfn data-x="concept-resolver-fulfill">fulfill</dfn> and <dfn data-x="concept-resolver-reject">reject</dfn> algorithms</li>
+
+    </ul>
+
+    <p>The term <dfn>throw</dfn> in this specification is used as defined in the DOM specification.
+    The following <code>DOMException</code> types are defined in the DOM specification: <a
+    href="#refsDOM">[DOM]</a></p>
+
+    <ol class="brief">
+     <li value="1"><dfn><code>IndexSizeError</code></dfn></li>
+     <li value="3"><dfn><code>HierarchyRequestError</code></dfn></li>
+     <li value="4"><dfn><code>WrongDocumentError</code></dfn></li>
+     <li value="5"><dfn><code>InvalidCharacterError</code></dfn></li>
+     <li value="7"><dfn><code>NoModificationAllowedError</code></dfn></li>
+     <li value="8"><dfn><code>NotFoundError</code></dfn></li>
+     <li value="9"><dfn><code>NotSupportedError</code></dfn></li>
+     <li value="11"><dfn><code>InvalidStateError</code></dfn></li>
+     <li value="12"><dfn><code>SyntaxError</code></dfn></li>
+     <li value="13"><dfn><code>InvalidModificationError</code></dfn></li>
+     <li value="14"><dfn><code>NamespaceError</code></dfn></li>
+     <li value="15"><dfn><code>InvalidAccessError</code></dfn></li>
+     <li value="18"><dfn><code>SecurityError</code></dfn></li>
+     <li value="19"><dfn><code>NetworkError</code></dfn></li>
+     <li value="20"><dfn><code>AbortError</code></dfn></li>
+     <li value="21"><dfn><code>URLMismatchError</code></dfn></li>
+     <li value="22"><dfn><code>QuotaExceededError</code></dfn></li>
+     <li value="23"><dfn><code>TimeoutError</code></dfn></li>
+     <li value="24"><dfn><code>InvalidNodeTypeError</code></dfn></li>
+     <li value="25"><dfn><code>DataCloneError</code></dfn></li>
+    </ol>
+
+    <p class="example">For example, to <i>throw a <code>TimeoutError</code> exception</i>, a user
+    agent would construct a <code>DOMException</code> object whose type was the string "<code
+    data-x="">TimeoutError</code>" (and whose code was the number 23, for legacy reasons) and
+    actually throw that object as an exception.</p>
+
+    <p>The following features are defined in the DOM Events specification: <a
+    href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
+
+    <ul class="brief">
+
+     <li><dfn><code>MouseEvent</code></dfn> interface</li>
+     <li><dfn><code>MouseEventInit</code></dfn> dictionary type</li>
+
+     <li>The <dfn><code>FocusEvent</code></dfn> interface and its <dfn data-x="dom-FocusEvent-relatedTarget"><code>relatedTarget</code></dfn> attribute</li>
+
+     <li>The <dfn><code>UIEvent</code></dfn> interface's <dfn data-x="dom-UIEvent-detail"><code>detail</code></dfn> attribute</li>
+
+     <li><dfn data-x="event-click"><code>click</code></dfn> event</li>
+     <li><dfn data-x="event-dblclick"><code>dblclick</code></dfn> event</li>
+     <li><dfn data-x="event-mousedown"><code>mousedown</code></dfn> event</li>
+     <li><dfn data-x="event-mouseenter"><code>mouseenter</code></dfn> event</li>
+     <li><dfn data-x="event-mouseleave"><code>mouseleave</code></dfn> event</li>
+     <li><dfn data-x="event-mousemove"><code>mousemove</code></dfn> event</li>
+     <li><dfn data-x="event-mouseout"><code>mouseout</code></dfn> event</li>
+     <li><dfn data-x="event-mouseover"><code>mouseover</code></dfn> event</li>
+     <li><dfn data-x="event-mouseup"><code>mouseup</code></dfn> event</li>
+     <li><dfn data-x="event-mousewheel"><code>mousewheel</code></dfn> event</li>
+
+     <li><dfn data-x="event-keydown"><code>keydown</code></dfn> event</li>
+     <li><dfn data-x="event-keyup"><code>keyup</code></dfn> event</li>
+     <li><dfn data-x="event-keypress"><code>keypress</code></dfn> event</li>
+
+    </ul>
+
+    <p>The following features are defined in the Touch Events specification: <a
+    href="#refsTOUCH">[TOUCH]</a></p>
+
+    <ul class="brief">
+
+     <li><dfn><code>Touch</code></dfn> interface</li>
+
+     <li><dfn>Touch point</dfn> concept</li>
+
+    </ul>
+
+    <p>This specification sometimes uses the term <dfn data-x="">name</dfn> to refer to the event's
+    <code data-x="dom-event-type">type</code>; as in, "an event named <code data-x="">click</code>"
+    or "if the event name is <code data-x="">keypress</code>". The terms "name" and "type" for
+    events are synonymous.</p>
+
+    <p>The following features are defined in the DOM Parsing and Serialisation specification: <a
+    href="#refsDOMPARSING">[DOMPARSING]</a></p>
+
+    <ul class="brief">
+     <li><dfn data-x="dom-innerHTML"><code>innerHTML</code></dfn></li>
+     <li><dfn data-x="dom-outerHTML"><code>outerHTML</code></dfn></li>
+    </ul>
+
+    <p class="note">User agents are also encouraged to implement the features described in the
+    <cite>HTML Editing APIs</cite> and <cite><code>UndoManager</code> and DOM Transaction</cite>
+    specifications.
+    <a href="#refsEDITING">[EDITING]</a>
+    <a href="#refsUNDO">[UNDO]</a>
+    </p>
+
+    <p>The following parts of the Fullscreen specification are referenced from this specification,
+    in part to define the rendering of <code>dialog</code> elements, and also to define how the
+    Fullscreen API interacts with the sandboxing features in HTML: <a
+    href="#refsFULLSCREEN">[FULLSCREEN]</a></p>
+
+    <ul class="brief">
+     <li>The <dfn>top layer</dfn> concept</li>
+     <li><dfn data-x="dom-element-requestFullscreen"><code>requestFullscreen()</code></dfn>
+     <li>The <dfn>fullscreen enabled flag</dfn></li>
+     <li>The <dfn>fully exit fullscreen</dfn> algorithm</li>
+    </ul>
+
+   </dd>
+
+
+
+   <dt>File API</dt>
+
+   <dd>
+
+    <p>This specification uses the following features defined in the File API specification: <a
+    href="#refsFILEAPI">[FILEAPI]</a></p>
+
+    <ul class="brief">
+
+     <li><dfn><code>Blob</code></dfn></li>
+     <li><dfn><code>File</code></dfn></li>
+     <li><dfn><code>FileList</code></dfn></li>
+     <li><dfn data-x="dom-Blob-close"><code>Blob.close()</code></dfn></li>
+     <li><dfn data-x="dom-Blob-type"><code>Blob.type</code></dfn></li>
+     <li>The concept of <dfn data-x="file-error-read">read errors</dfn></li>
+    </ul>
+
+   </dd>
+
+
+   <dt>XMLHttpRequest</dt>
+
+   <dd>
+
+    <p>This specification references the XMLHttpRequest specification to describe how the two
+    specifications interact and to use its <code>ProgressEvent</code> features. The following
+    features and terms are defined in the XMLHttpRequest specification: <a
+    href="#refsXHR">[XHR]</a></p>
+
+    <ul class="brief">
+
+     <li><dfn><code>XMLHttpRequest</code></dfn>
+     <li><dfn><code>ProgressEvent</code></dfn>
+     <li><dfn data-x="fire a progress event">Fire a progress event named <var data-x="">e</var></dfn>
+
+    </ul>
+
+   </dd>
+
+
+<!--TOPIC:HTML-->
+
+   <dt>Media Queries</dt>
+
+   <dd>
+
+    <p>Implementations must support the Media Queries language. <a href="#refsMQ">[MQ]</a></p>
+
+   </dd>
+
+
+   <dt>CSS modules</dt>
+
+   <dd>
+
+    <p>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.</p>
+
+    <p>In particular, some features require that a string be <dfn>parsed as a CSS &lt;color&gt;
+    value</dfn>. 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. <a
+    href="#refsCSSCOLOR">[CSSCOLOR]</a> <a href="#refsCSS">[CSS]</a></p>
+
+    <p class="example">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 "<code
+    data-x="">rgb(0,0,0</code>" (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 "<code data-x="">rgb(0,0,</code>" (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.</p>
+
+    <p>The term <dfn>CSS element reference identifier</dfn> is used as defined in the <cite>CSS
+    Image Values and Replaced Content</cite> specification to define the API that declares
+    identifiers for use with the CSS 'element()' function. <a
+    href="#refsCSSIMAGES">[CSSIMAGES]</a></p>
+
+    <p>Similarly, the term <dfn>provides a paint source</dfn> is used as defined in the <cite>CSS
+    Image Values and Replaced Content</cite> specification to define the interaction of certain HTML
+    elements with the CSS 'element()' function. <a href="#refsCSSIMAGES">[CSSIMAGES]</a></p>
+
+    <p>The term <dfn>default object size</dfn> is also defined in the <cite>CSS Image Values and
+    Replaced Content</cite> specification. <a href="#refsCSSIMAGES">[CSSIMAGES]</a></p>
+
+    <p>Implementations that support scripting must support the CSS Object Model. The following
+    features and terms are defined in the CSSOM specifications: <a href="#refsCSSOM">[CSSOM]</a> <a
+    href="#refsCSSOMVIEW">[CSSOMVIEW]</a>
+
+    <ul class="brief">
+     <li><dfn><code>Screen</code></dfn></li>
+     <li><dfn><code>LinkStyle</code></dfn></li>
+     <li><dfn><code>CSSStyleDeclaration</code></dfn></li>
+     <li><dfn data-x="dom-CSSStyleDeclaration-cssText"><code>cssText</code></dfn> attribute of <code>CSSStyleDeclaration</code></li>
+     <li><dfn><code>StyleSheet</code></dfn></li>
+     <li>The terms <dfn>create a CSS style sheet</dfn>, <dfn>remove a CSS style sheet</dfn>, and <dfn>associated CSS style sheet</dfn></li>
+     <li><dfn data-x="CSS style sheet">CSS style sheets</dfn> and their properties:
+         <dfn data-x="concept-css-style-sheet-type">type</dfn>,
+         <dfn data-x="concept-css-style-sheet-location">location</dfn>,
+         <dfn data-x="concept-css-style-sheet-parent-CSS-style-sheet">parent CSS style sheet</dfn>,
+         <dfn data-x="concept-css-style-sheet-owner-node">owner node</dfn>,
+         <dfn data-x="concept-css-style-sheet-owner-CSS-rule">owner CSS rule</dfn>,
+         <dfn data-x="concept-css-style-sheet-media">media</dfn>,
+         <dfn data-x="concept-css-style-sheet-title">title</dfn>,
+         <dfn data-x="concept-css-style-sheet-alternate-flag">alternate flag</dfn>,
+         <dfn data-x="concept-css-style-sheet-disabeld-flag">disabled flag</dfn>,
+         <dfn data-x="concept-css-style-sheet-CSS-rules">CSS rules</dfn>,
+         <dfn data-x="concept-css-style-sheet-origin-clean-flag">origin-clean flag</dfn>
+     </li>
+     <li><dfn>Alternative style sheet sets</dfn> and the <dfn>preferred style sheet set</dfn></li>
+     <li><dfn>Serializing a CSS value</dfn></li>
+     <li><dfn>Scroll an element into view</dfn></li>
+     <li><dfn>Scroll to the beginning of the document</dfn></li>
+     <li>The <dfn data-x="event-resize"><code>resize</code></dfn> event</li>
+     <li>The <dfn data-x="event-scroll"><code>scroll</code></dfn> event</li>
+    </ul>
+
+    <p>The term <dfn>environment encoding</dfn> is defined in the <cite>CSS Syntax</cite>
+    specifications. <a href="#refsCSSSYNTAX">[CSSSYNTAX]</a></p>
+
+    <p>The term <dfn>CSS styling attribute</dfn> is defined in the <cite>CSS Style Attributes</cite>
+    specification. <a href="#refsCSSATTR">[CSSATTR]</a></p>
+
+    <p>The <code>CanvasRenderingContext2D</code> object's use of fonts depends on the features
+    described in the CSS <cite>Fonts</cite> and <cite>Font Load Events</cite> specifications, including in particular
+    <dfn><code>FontLoader</code></dfn>. <a href="#refsCSSFONTS">[CSSFONTS]</a> <a
+    href="#refsCSSFONTLOAD">[CSSFONTLOAD]</a></p>
+
+   </dd>
+
+
+<!--TOPIC:Canvas-->
+
+   <dt>SVG</dt>
+
+   <dd>
+
+    <p>The following interface is defined in the SVG specification: <a href="#refsSVG">[SVG]</a></p>
+
+    <ul class="brief">
+     <li><dfn><code>SVGMatrix</code></dfn>
+    </ul>
+
+    <!-- mention that the parser supports it? -->
+
+   </dd>
+
+
+   <dt>WebGL</dt>
+
+   <dd>
+
+    <p>The following interface is defined in the WebGL specification: <a
+    href="#refsWEBGL">[WEBGL]</a></p>
+
+    <ul class="brief">
+     <li><dfn><code>WebGLRenderingContext</code></dfn>
+    </ul>
+
+   </dd>
+
+
+<!--TOPIC:HTML-->
+
+   <!-- mention that the parser supports mathml? -->
+
+
+<!--TOPIC:Video Text Tracks-->
+
+   <dt>WebVTT</dt>
+
+   <dd>
+
+    <p>Implementations may support <dfn>WebVTT</dfn> as a text track format for subtitles, captions,
+    chapter titles, metadata, etc, for media resources. <a href="#refsWEBVTT">[WEBVTT]</a></p>
+
+    <p>The following terms, used in this specification, are defined in the WebVTT specification:</p>
+
+    <ul class="brief">
+     <li><dfn>WebVTT file</dfn>
+     <li><dfn>WebVTT file using cue text</dfn>
+     <li><dfn>WebVTT file using chapter title text</dfn>
+     <li><dfn>WebVTT file using only nested cues</dfn>
+     <li><dfn>WebVTT parser</dfn>
+     <li>The <dfn>rules for updating the display of WebVTT text tracks</dfn>
+     <li>The <dfn>rules for interpreting WebVTT cue text</dfn>
+     <li>The WebVTT <dfn>text track cue writing direction</dfn>
+    </ul>
+
+   </dd>
+
+
+<!--TOPIC:WebSocket API-->
+
+   <dt>The WebSocket protocol</dt>
+
+   <dd>
+
+    <p>The following terms are defined in the WebSocket protocol specification: <a
+    href="#refsWSP">[WSP]</a></p>
+
+    <ul class="brief">
+
+     <li><dfn>establish a WebSocket connection</dfn>
+     <li><dfn>the WebSocket connection is established</dfn>
+     <li><dfn>validate the server's response</dfn>
+     <li><dfn>extensions in use</dfn>
+     <li><dfn>subprotocol in use</dfn>
+     <li><dfn>headers to send appropriate cookies</dfn>
+     <li><dfn>cookies set during the server's opening handshake</dfn>
+     <li><dfn>a WebSocket message has been received</dfn>
+     <li><dfn>send a WebSocket Message</dfn>
+     <li><dfn>fail the WebSocket connection</dfn>
+     <li><dfn>close the WebSocket connection</dfn>
+     <li><dfn>start the WebSocket closing handshake</dfn>
+     <li><dfn>the WebSocket closing handshake is started</dfn>
+     <li><dfn>the WebSocket connection is closed</dfn> (possibly <i data-x="">cleanly</i>)
+     <li><dfn>the WebSocket connection close code</dfn>
+     <li><dfn>the WebSocket connection close reason</dfn>
+
+    </ul>
+
+   </dd>
+
+
+<!--TOPIC:HTML-->
+
+   <dt>ARIA</dt>
+
+   <dd>
+
+    <p>The terms <dfn>strong native semantics</dfn> is used as defined in the ARIA specification.
+    The term <dfn>default implicit ARIA semantics</dfn> has the same meaning as the term <i>implicit
+    WAI-ARIA semantics</i> as used in the ARIA specification. <a href="#refsARIA">[ARIA]</a></p>
+
+    <p>The <dfn data-x="attr-aria-role"><code>role</code></dfn> and <code data-x="">aria-*</code>
+    attributes are defined in the ARIA specification. <a href="#refsARIA">[ARIA]</a></p>
+
+
+   </dd>
+
+
+  </dl>
+
+  <p>This specification does not <em>require</em> 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.</p>
+
+  <p>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. <a
+  href="#refsHTTP">[HTTP]</a> <a href="#refsORIGIN">[ORIGIN]</a> <a
+  href="#refsCOOKIES">[COOKIES]</a></p>
+
+  <p class="note">This specification might have certain additional requirements on character
+  encodings, image formats, audio formats, and video formats in the respective sections.</p>
+
+  </div>
+
+  </div>
+
+
+  <h4>Extensibility</h4>
+
+  <p>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.</p>
+
+  <div class="nodev">
+
+  <p>If such extensions are nonetheless needed, e.g. for experimental purposes, then vendors are
+  strongly urged to use one of the following extension mechanisms:</p>
+
+  <ul>
+
+   <li><p>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.</p>
+
+   <li>
+
+    <p>For markup-level features that are intended for use with <span>the HTML syntax</span>,
+    extensions should be limited to new attributes of the form "<code data-x="">x-<var
+    data-x="">vendor</var>-<var data-x="">feature</var></code>", where <var data-x="">vendor</var> is a
+    short string that identifies the vendor responsible for the extension, and <var
+    data-x="">feature</var> 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 "<code
+    data-x="">x-<var data-x="">vendor</var>-<var data-x="">feature</var></code>" form allows extensions
+    to be made without risk of conflicting with future additions to the specification.</p>
+
+    <div class="example">
+
+     <p>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:</p>
+
+     <pre>&lt;p>This smells of lemons!
+&lt;span x-ferret-smellovision x-ferret-smellcode="LEM01"
+      x-mb-outputsmell x-mb-smell="lemon juice">&lt;/span>&lt;/p></pre>
+
+    </div>
+
+   </li>
+
+  </ul>
+
+  <p>Attribute names beginning with the two characters "<code data-x="">x-</code>" 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.</p>
+
+  <p class="note">Pages that use such attributes are by definition non-conforming.</p>
+
+  <p>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.</p>
+
+  <p>For events, experimental event types should be prefixed with vendor-specific strings.</p>
+
+  <div class="example">
+
+   <p>For example, if a user agent called "Pleas<!--e h-->old" were to add an event to indicate when
+   the user is going up in an elevator, it could use the prefix "<code data-x="">pleasold</code>" and
+   thus name the event "<code data-x="">pleasoldgoingup</code>", possibly with an event handler
+   attribute named "<code data-x="">onpleasoldgoingup</code>".</p>
+
+  </div>
+
+  <p>All extensions must be defined so that the use of extensions neither contradicts nor causes the
+  non-conformance of functionality defined in the specification.</p> <!-- thanks to QA Framework -->
+
+  <div class="example">
+
+   <p>For example, while strongly discouraged from doing so, an implementation "Foo Browser" could
+   add a new IDL attribute "<code data-x="">fooTypeTime</code>" 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 <code
+   data-x="dom-form-elements">elements</code> array would be in violation of the above requirement,
+   as it would violate the definition of <code data-x="dom-form-elements">elements</code> given in
+   this specification.</p>
+
+  </div>
+
+  <p>When adding new <span data-x="reflect">reflecting</span> IDL attributes corresponding to content
+  attributes of the form "<code data-x="">x-<var data-x="">vendor</var>-<var
+  data-x="">feature</var></code>", the IDL attribute should be named "<code data-x=""><var
+  data-x="">vendor</var><var data-x="">Feature</var></code>" (i.e. the "<code data-x="">x</code>" is
+  dropped from the IDL attribute's name).</p>
+
+  </div>
+
+  <hr>
+
+  <p>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 <dfn data-x="other applicable specifications">applicable specification</dfn> for the purposes of
+  conformance requirements in this specification.</p>
+
+  <p class="note">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 <em>agrees</em> is
+  applicable.</p>
+
+  <div class="nodev">
+
+  <hr>
+
+  <p>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.</p>
+
+<!--ADD-TOPIC:Security-->
+  <p>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
+  &mdash; leaving the attribute on the object but making it return null or throw an exception is
+  insufficient.</p>
+<!--REMOVE-TOPIC:Security-->
+
+  </div>
+
+
+  <div class="nodev">
+
+  <h4>Interactions with XPath and XSLT</h4>
+
+  <p id="xpath-1.0-processors">Implementations of XPath 1.0 that operate on <span>HTML
+  documents</span> parsed or created in the manners described in this specification (e.g. as part of
+  the <code data-x="">document.evaluate()</code> API) must act as if the following edit was applied
+  to the XPath 1.0 specification.</p>
+
+  <p>First, remove this paragraph:</p>
+
+  <blockquote cite="http://www.w3.org/TR/1999/REC-xpath-19991116#node-tests">
+
+   <p>A <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> in the node test is expanded
+   into an <a href="http://www.w3.org/TR/1999/REC-xpath-19991116#dt-expanded-name">expanded-name</a>
+   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
+   <code data-x="">xmlns</code> is not used: if the <a
+   href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> 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
+   <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> has a prefix for which there is
+   no namespace declaration in the expression context.</p>
+
+  </blockquote>
+
+  <p>Then, insert in its place the following:</p>
+
+  <blockquote cite="http://www.w3.org/Bugs/Public/show_bug.cgi?id=7059#c37">
+
+   <p>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<!-- added 2009-10-27
+   - http://www.w3.org/Bugs/Public/show_bug.cgi?id=8062 --> namespace declaration for this prefix in
+   the expression context, and the corresponding<!-- typo fixed 2009-10-27 -
+   http://www.w3.org/Bugs/Public/show_bug.cgi?id=8063 --> 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. </p>
+
+   <p>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:</p>
+
+   <ol>
+
+    <li>If the context node is from an HTML DOM, the default element namespace is
+    "http://www.w3.org/1999/xhtml".</li>
+
+    <li>Otherwise, the default element namespace URI is null.</li>
+
+   </ol>
+
+   <p class="note">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.</p>
+
+  </blockquote>
+
+  <p class="note">This change is a <span>willful violation</span> 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. <a href="#refsXPATH10">[XPATH10]</a></p> <!-- note: version matters for
+  this ref -->
+
+  <hr>
+
+  <p id="dom-based-xslt-1.0-processors">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:</p>
+
+  <p>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
+  <span>HTML namespace</span>, <span data-x="converted to ASCII lowercase">ASCII-lowercase</span> the
+  element's local name, and <span data-x="converted to ASCII lowercase">ASCII-lowercase</span> the
+  names of any non-namespaced attributes on the element.</p>
+
+  <p class="note">This requirement is a <span>willful violation</span> 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.) <a
+  href="#refsXSLT10">[XSLT10]</a></p> <!-- note: version matters for this ref -->
+
+  <hr>
+
+  <p>This specification does not specify precisely how XSLT processing interacts with the <span>HTML
+  parser</span> infrastructure (for example, whether an XSLT processor acts as if it puts any
+  elements into a <span>stack of open elements</span>). However, XSLT processors must <span>stop
+  parsing</span> if they successfully complete, and must set the <span>current document
+  readiness</span> first to "<code data-x="">interactive</code>"<!-- this synchronously fires an
+  event --> and then to "<code data-x="">complete</code>"<!-- this also synchronously fires an event
+  --> if they are aborted.</p>
+
+  <hr>
+
+  <p>This specification does not specify how XSLT interacts with the <span
+  data-x="navigate">navigation</span> algorithm, how it fits in with the <span>event loop</span>, 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).</p>
+
+  <p class="note">There are also additional non-normative comments regarding the interaction of XSLT
+  and HTML <a href="#scriptTagXSLT">in the <code>script</code> element section</a>, and of
+  XSLT, XPath, and HTML <a href="#template-XSLT-XPath">in the <code>template</code> element
+  section</a>.</p>
+
+  </div>
+
+
+
+
+  <h3>Case-sensitivity and string comparison</h3>
+
+  <p>Comparing two strings in a <dfn>case-sensitive</dfn> manner means comparing them exactly, code
+  point for code point.</p>
+
+  <p>Comparing two strings in an <dfn>ASCII case-insensitive</dfn> 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.</p>
+
+  <p>Comparing two strings in a <dfn>compatibility caseless</dfn> manner means using the Unicode
+  <i>compatibility caseless match</i> operation to compare the two strings, with no language-specific tailoirings. <a
+  href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p>Except where otherwise stated, string comparisons must be performed in a
+  <span>case-sensitive</span> manner.</p>
+
+
+  <div class="nodev">
+
+  <p><dfn data-x="converted to ASCII uppercase">Converting a string to ASCII uppercase</dfn> 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).</p>
+
+  <p><dfn data-x="converted to ASCII lowercase">Converting a string to ASCII lowercase</dfn> 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).</p>
+
+  </div>
+
+
+  <p>A string <var data-x="">pattern</var> is a <dfn>prefix match</dfn> for a string <var
+  data-x="">s</var> when <var data-x="">pattern</var> is not longer than <var data-x="">s</var> and
+  truncating <var data-x="">s</var> to <var data-x="">pattern</var>'s length leaves the two strings as
+  matches of each other.</p>
+
+
+
+  <h3>Common microsyntaxes</h3>
+
+  <p>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.</p>
+
+  <div class="nodev">
+
+  <p class="note">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.</p>
+
+  </div>
+
+
+  <div class="nodev">
+
+  <h4>Common parser idioms</h4>
+
+  </div>
+
+  <p>The <dfn data-x="space character">space characters</dfn>, 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).</p>
+
+  <p>The <dfn data-x="White_Space">White_Space characters</dfn> are those that have the Unicode
+  property "White_Space" in the Unicode <code data-x="">PropList.txt</code> data file. <a
+  href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p class="note">This should not be confused with the "White_Space" value (abbreviated "WS") of the
+  "Bidi_Class" property in the <code data-x="">Unicode.txt</code> data file.</p>
+
+  <p>The <dfn>control characters</dfn> are those whose Unicode "General_Category" property has the
+  value "Cc" in the Unicode <code data-x="">UnicodeData.txt</code> data file. <a
+  href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p>The <dfn>uppercase ASCII letters</dfn> are the characters in the range U+0041 LATIN CAPITAL
+  LETTER A to U+005A LATIN CAPITAL LETTER Z.</p>
+
+  <p>The <dfn>lowercase ASCII letters</dfn> are the characters in the range U+0061 LATIN SMALL
+  LETTER A to U+007A LATIN SMALL LETTER Z.</p>
+
+  <p>The <dfn>ASCII digits</dfn> are the characters in the range U+0030 DIGIT ZERO (0) to U+0039
+  DIGIT NINE (9).</p>
+
+  <p>The <dfn>alphanumeric ASCII characters</dfn> are those that are either <span>uppercase ASCII
+  letters</span>, <span>lowercase ASCII letters</span>, or <span>ASCII digits</span>.</p>
+
+  <p>The <dfn>ASCII hex digits</dfn> 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.</p>
+
+  <p>The <dfn>uppercase ASCII hex digits</dfn> 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.</p>
+
+  <p>The <dfn>lowercase ASCII hex digits</dfn> 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.</p>
+
+  <div class="nodev">
+
+  <p>Some of the micro-parsers described below follow the pattern of having an <var
+  data-x="">input</var> variable that holds the string being parsed, and having a <var
+  data-x="">position</var> variable pointing at the next character to parse in <var
+  data-x="">input</var>.</p>
+
+  <p>For parsers based on this pattern, a step that requires the user agent to <dfn>collect a
+  sequence of characters</dfn> means that the following algorithm must be run, with <var
+  data-x="">characters</var> being the set of characters that can be collected:</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> and <var data-x="">position</var> be the same variables as
+   those of the same name in the algorithm that invoked these steps.</p></li>
+
+   <li><p>Let <var data-x="">result</var> be the empty string.</p></li>
+
+   <li><p>While <var data-x="">position</var> doesn't point past the end of <var data-x="">input</var>
+   and the character at <var data-x="">position</var> is one of the <var data-x="">characters</var>,
+   append that character to the end of <var data-x="">result</var> and advance <var
+   data-x="">position</var> to the next character in <var data-x="">input</var>.</p></li>
+
+   <li><p>Return <var data-x="">result</var>.</p></li>
+
+  </ol>
+
+  <p>The step <dfn>skip whitespace</dfn> means that the user agent must <span>collect a sequence of
+  characters</span> that are <span data-x="space character">space characters</span>. The step
+  <dfn>skip White_Space characters</dfn> means that the user agent must <span>collect a sequence of
+  characters</span> that are <span>White_Space</span> characters. In both cases, the collected
+  characters are not used. <a href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p>When a user agent is to <dfn>strip line breaks</dfn> from a string, the user agent must remove
+  any U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) characters from that string.</p>
+
+  <p>When a user agent is to <dfn>strip leading and trailing whitespace</dfn> from a string, the
+  user agent must remove all <span data-x="space character">space characters</span> that are at the
+  start or end of the string.</p>
+
+  <p>When a user agent is to <dfn>strip and collapse whitespace</dfn> in a string, it must replace
+  any sequence of one or more consecutive <span data-x="space character">space characters</span> in
+  that string with a single U+0020 SPACE character, and then <span>strip leading and trailing
+  whitespace</span> from that string.</p>
+
+  <p>When a user agent has to <dfn>strictly split a string</dfn> on a particular delimiter character
+  <var data-x="">delimiter</var>, it must use the following algorithm:</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p>Let <var data-x="">tokens</var> be an ordered list of tokens, initially empty.</p></li>
+
+   <li><p>While <var data-x="">position</var> is not past the end of <var data-x="">input</var>:</p>
+
+    <ol>
+
+     <li><p><span>Collect a sequence of characters</span> that are not the <var
+     data-x="">delimiter</var> character.</p></li>
+
+     <li><p>Append the string collected in the previous step to <var data-x="">tokens</var>.</p></li>
+
+     <li><p>Advance <var data-x="">position</var> to the next character in <var
+     data-x="">input</var>.</p></li> <!-- skips past the delimiter -->
+
+    </ol>
+
+   </li>
+
+   <li><p>Return <var data-x="">tokens</var>.</p></li>
+
+  </ol>
+
+  <p class="note">For the special cases of splitting a string <span data-x="split a string on
+  spaces">on spaces</span> and <span data-x="split a string on commas">on commas</span>, this
+  algorithm does not apply (those algorithms also perform <span data-x="strip leading and trailing
+  whitespace">whitespace trimming</span>).</p>
+
+  </div>
+
+
+
+  <h4>Boolean attributes</h4>
+
+  <p>A number of attributes are <dfn data-x="boolean attribute">boolean attributes</dfn>. The
+  presence of a boolean attribute on an element represents the true value, and the absence of the
+  attribute represents the false value.</p>
+
+  <p>If the attribute is present, its value must either be the empty string or a value that is an
+  <span>ASCII case-insensitive</span> match for the attribute's canonical name, with no leading or
+  trailing whitespace.</p>
+
+  <p class="note">The values "true" and "false" are not allowed on boolean attributes. To represent
+  a false value, the attribute has to be omitted altogether.</p>
+
+  <div class="example">
+
+   <p>Here is an example of a checkbox that is checked and disabled. The <code
+   data-x="attr-input-checked">checked</code> and <code data-x="attr-fe-disabled">disabled</code>
+   attributes are the boolean attributes.</p>
+
+   <pre>&lt;label>&lt;input type=checkbox checked name=cheese disabled> Cheese&lt;/label></pre>
+
+   <p>This could be equivalently written as this:
+
+   <pre>&lt;label>&lt;input type=checkbox checked=checked name=cheese disabled=disabled> Cheese&lt;/label></pre>
+
+   <p>You can also mix styles; the following is still equivalent:</p>
+
+   <pre>&lt;label>&lt;input type='checkbox' checked name=cheese disabled=""> Cheese&lt;/label></pre>
+
+  </div>
+
+
+
+  <h4>Keywords and enumerated attributes</h4>
+
+  <p>Some attributes are defined as taking one of a finite set of keywords. Such attributes are
+  called <dfn data-x="enumerated attribute">enumerated attributes</dfn>. The keywords are each
+  defined to map to a particular <em>state</em> (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 <i>invalid value default</i>, the
+  second is the <i>missing value default</i>.</p>
+
+  <p>If an enumerated attribute is specified, the attribute's value must be an <span>ASCII
+  case-insensitive</span> match for one of the given keywords that are not said to be
+  non-conforming, with no leading or trailing whitespace.</p>
+
+  <p>When the attribute is specified, if its value is an <span>ASCII case-insensitive</span> 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
+  <i>invalid value default</i>, then the attribute represents that state. Otherwise, if the
+  attribute value matches none of the keywords but there is a <i>missing value default</i> state
+  defined, then <em>that</em> is the state represented by the attribute. Otherwise, there is no
+  default, and invalid values mean that there is no state represented.</p>
+
+  <p>When the attribute is <em>not</em> specified, if there is a <i>missing value default</i> 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.</p>
+
+  <p class="note">The empty string can be a valid keyword.</p>
+
+
+  <h4>Numbers</h4>
+
+  <h5>Signed integers</h5>
+
+  <p>A string is a <dfn>valid integer</dfn> if it consists of one or more <span>ASCII digits</span>,
+  optionally prefixed with a U+002D HYPHEN-MINUS character (-).</p>
+
+  <p>A <span>valid integer</span> without a U+002D HYPHEN-MINUS (-) prefix represents the number
+  that is represented in base ten by that string of digits. A <span>valid integer</span>
+  <em>with</em> 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.</p>
+
+  <div class="nodev">
+
+  <p>The <dfn>rules for parsing integers</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p>Let <var data-x="">sign</var> have the value "positive".</p></li>
+
+   <li><p><span>Skip whitespace</span>.</p></li>
+
+   <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+    error.</p></li>
+
+   <li>
+
+    <p>If the character indicated by <var data-x="">position</var> (the first character) is a U+002D
+    HYPHEN-MINUS character (-):</p>
+
+    <ol>
+
+     <li>Let <var data-x="">sign</var> be "negative".</li>
+
+     <li>Advance <var data-x="">position</var> to the next character.</li>
+
+     <li>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+     error.</li>
+
+    </ol>
+
+    <p>Otherwise, if the character indicated by <var data-x="">position</var> (the first character)
+    is a U+002B PLUS SIGN character (+):</p>
+
+    <ol>
+
+     <li>Advance <var data-x="">position</var> to the next character. (The "<code data-x="">+</code>"
+     is ignored, but it is not conforming.)</li>
+
+     <li>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+     error.</li>
+
+    </ol>
+
+   </li>
+
+   <li><p>If the character indicated by <var data-x="">position</var> is not an <span data-x="ASCII
+   digits">ASCII digit</span>, then return an error.</p></li>
+
+   <!-- Ok. At this point we know we have a number. It might have
+   trailing garbage which we'll ignore, but it's a number, and we
+   won't return an error. -->
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>, and
+   interpret the resulting sequence as a base-ten integer. Let <var data-x="">value</var> be that
+   integer.</p></li>
+
+   <li><p>If <var data-x="">sign</var> is "positive", return <var
+   data-x="">value</var>, otherwise return the result of subtracting
+   <var data-x="">value</var> from zero.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h5>Non-negative integers</h5>
+
+  <p>A string is a <dfn>valid non-negative integer</dfn> if it consists of one or more <span>ASCII
+  digits</span>.</p>
+
+  <p>A <span>valid non-negative integer</span> represents the number that is represented in base ten
+  by that string of digits.</p>
+
+  <div class="nodev">
+
+  <p>The <dfn>rules for parsing non-negative integers</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">value</var> be the result of parsing <var data-x="">input</var> using the
+   <span>rules for parsing integers</span>.</p></li>
+
+   <li><p>If <var data-x="">value</var> is an error, return an error.</p></li>
+
+   <li><p>If <var data-x="">value</var> is less than zero, return an error.</p></li>
+
+   <li><p>Return <var data-x="">value</var>.</p></li>
+
+  </ol>
+
+  <!-- Implications: A leading + is ignored. A leading - is ignored if the value is zero. -->
+
+  </div>
+
+
+  <h5>Floating-point numbers</h5>
+
+  <p>A string is a <dfn>valid floating-point number</dfn> if it consists of:</p>
+
+  <ol class="brief">
+
+   <li>Optionally, a U+002D HYPHEN-MINUS character (-).</li>
+
+   <li>One or both of the following, in the given order:
+
+    <ol>
+
+     <li>A series of one or more <span>ASCII digits</span>.</li>
+
+     <li>
+
+      <ol>
+
+       <li>A single U+002E FULL STOP character (.).</li>
+
+       <li>A series of one or more <span>ASCII digits</span>.</li>
+
+      </ol>
+
+     </li>
+
+    </ol>
+
+   </li>
+
+   <li>Optionally:
+
+    <ol>
+
+     <li>Either a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E
+     character (E).</li>
+
+     <li>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character (+).</li>
+
+     <li>A series of one or more <span>ASCII digits</span>.</li>
+
+    </ol>
+
+   </li>
+
+  </ol>
+
+  <p>A <span>valid floating-point number</span> 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.</p>
+
+  <p class="note">The Infinity and Not-a-Number (NaN) values are not <span data-x="valid
+  floating-point number">valid floating-point numbers</span>.</p>
+
+  <div class="nodev">
+
+  <p>The <dfn data-x="best representation of the number as a floating-point number">best
+  representation of the number <var data-x="">n</var> as a floating-point number</dfn> is the string
+  obtained from applying the JavaScript operator ToString to <var data-x="">n</var>. 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).</p>
+
+  <p>The <dfn>rules for parsing floating-point number values</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p>Let <var data-x="">value</var> have the value 1.</li>
+
+   <li><p>Let <var data-x="">divisor</var> have the value 1.</p></li>
+
+   <li><p>Let <var data-x="">exponent</var> have the value 1.</p></li>
+
+   <li><p><span>Skip whitespace</span>.</p></li>
+
+   <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+   error.</p></li>
+
+   <li>
+
+    <p>If the character indicated by <var data-x="">position</var> is a U+002D HYPHEN-MINUS character
+    (-):</p>
+
+    <ol>
+
+     <li>Change <var data-x="">value</var> and <var data-x="">divisor</var> to &#x2212;1.</li>
+
+     <li>Advance <var data-x="">position</var> to the next character.</li>
+
+     <li>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+     error.</li>
+
+    </ol>
+
+    <p>Otherwise, if the character indicated by <var data-x="">position</var> (the first character)
+    is a U+002B PLUS SIGN character (+):</p>
+
+    <ol>
+
+     <li>Advance <var data-x="">position</var> to the next character. (The "<code data-x="">+</code>"
+     is ignored, but it is not conforming.)</li>
+
+     <li>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+     error.</li>
+
+    </ol>
+
+   </li>
+
+   <li><p>If the character indicated by <var data-x="">position</var> is a U+002E FULL STOP (.), and
+   that is not the last character in <var data-x="">input</var>, and the character after the
+   character indicated by <var data-x="">position</var> is an <span data-x="ASCII digits">ASCII
+   digit</span>, then set <var data-x="">value</var> to zero and jump to the step labeled
+   <i>fraction</i>.</p> <!-- we have to check there's a number so that ".e1" fails to parse but ".0"
+   does not -->
+
+   <li><p>If the character indicated by <var data-x="">position</var> is not an <span data-x="ASCII
+   digits">ASCII digit</span>, then return an error.</p></li>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>, and
+   interpret the resulting sequence as a base-ten integer. Multiply <var data-x="">value</var> by
+   that integer.</p></li>
+
+   <li>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, jump to the
+   step labeled <i>conversion</i>.</li>
+
+   <li><p><i>Fraction</i>: If the character indicated by <var data-x="">position</var> is a U+002E
+   FULL STOP (.), run these substeps:</p>
+
+    <ol>
+
+     <li><p>Advance <var data-x="">position</var> to the next character.</p></li>
+
+     <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, or if the
+     character indicated by <var data-x="">position</var> is not an <span data-x="ASCII digits">ASCII
+     digit</span>, U+0065 LATIN SMALL LETTER E (e), or U+0045 LATIN CAPITAL LETTER E (E), then jump
+     to the step labeled <i>conversion</i>.</li>
+
+     <li><p>If the character indicated by <var data-x="">position</var> 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.</p>
+
+     <li><p><i>Fraction loop</i>: Multiply <var data-x="">divisor</var> by ten.</p></li>
+
+     <li>Add the value of the character indicated by <var data-x="">position</var>, interpreted as a
+     base-ten digit (0..9) and divided by <var data-x="">divisor</var>, to <var
+     data-x="">value</var>.</li>
+
+     <li><p>Advance <var data-x="">position</var> to the next character.</p></li>
+
+     <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, then jump
+     to the step labeled <i>conversion</i>.</li>
+
+     <li><p>If the character indicated by <var data-x="">position</var> is an <span data-x="ASCII
+     digits">ASCII digit</span>, jump back to the step labeled <i>fraction loop</i> in these
+     substeps.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>If the character indicated by <var data-x="">position</var> is a U+0065 LATIN SMALL LETTER
+   E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E), run these substeps:</p>
+
+    <ol>
+
+     <li><p>Advance <var data-x="">position</var> to the next character.</p></li>
+
+     <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, then jump
+     to the step labeled <i>conversion</i>.</li>
+
+     <li>
+
+      <p>If the character indicated by <var data-x="">position</var> is a U+002D HYPHEN-MINUS
+      character (-):</p>
+
+      <ol>
+
+       <li>Change <var data-x="">exponent</var> to &#x2212;1.</li>
+
+       <li>Advance <var data-x="">position</var> to the next character.</li>
+
+       <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, then
+       jump to the step labeled <i>conversion</i>.</li>
+
+      </ol>
+
+      <p>Otherwise, if the character indicated by <var data-x="">position</var> is a U+002B PLUS SIGN
+      character (+):</p>
+
+      <ol>
+
+       <li>Advance <var data-x="">position</var> to the next character.</li>
+
+       <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, then
+       jump to the step labeled <i>conversion</i>.</li>
+
+      </ol>
+
+     </li>
+
+     <li><p>If the character indicated by <var data-x="">position</var> is not an <span data-x="ASCII
+     digits">ASCII digit</span>, then jump to the step labeled <i>conversion</i>.</li>
+
+     <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>, and
+     interpret the resulting sequence as a base-ten integer. Multiply <var data-x="">exponent</var>
+     by that integer.</p></li>
+
+     <li><p>Multiply <var data-x="">value</var> by ten raised to the <var data-x="">exponent</var>th
+     power.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p><i>Conversion</i>: Let <var data-x="">S</var> be the set of finite IEEE 754
+   double-precision floating-point values except &#x2212;0, but with two special values added: 2<sup
+   data-x="">1024</sup> and &#x2212;2<sup data-x="">1024</sup>.</p></li>
+
+   <li><p>Let <var data-x="">rounded-value</var> be the number in <var data-x="">S</var> that is
+   closest to <var data-x="">value</var>, selecting the number with an even significand if there are
+   two equally close values. (The two special values 2<sup data-x="">1024</sup> and &#x2212;2<sup
+   data-x="">1024</sup> are considered to have even significands for this purpose.)</p></li>
+
+   <li><p>If <var data-x="">rounded-value</var> is 2<sup data-x="">1024</sup> or &#x2212;2<sup
+   data-x="">1024</sup>, return an error.</p></li>
+
+   <li><p>Return <var data-x="">rounded-value</var>.</p></li>
+
+  </ol>
+
+  </div>
+
+
+<div class="nodev">
+  <h5 id="percentages-and-dimensions">Percentages and lengths</h5>
+
+  <p>The <dfn>rules for parsing dimension values</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p><span>Skip whitespace</span>.</p></li>
+
+   <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+   error.</p></li>
+
+   <li><p>If the character indicated by <var data-x="">position</var> is a U+002B PLUS SIGN character
+   (+), advance <var data-x="">position</var> to the next character.</li>
+
+   <li><p><span>Collect a sequence of characters</span> that are U+0030 DIGIT ZERO (0) characters,
+   and discard them.</p></li>
+
+   <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return an
+   error.</p></li>
+
+   <li><p>If the character indicated by <var data-x="">position</var> is not one of U+0031 DIGIT ONE
+   (1) to U+0039 DIGIT NINE (9), then return an error.</p></li>
+
+   <!-- Ok. At this point we know we have a number. It might have trailing garbage which we'll
+   ignore, but it's a number, and we won't return an error. -->
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>, and
+   interpret the resulting sequence as a base-ten integer. Let <var data-x="">value</var> be that
+   number.</li>
+
+   <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return <var
+   data-x="">value</var> as a length.</p></li>
+
+   <li>
+
+    <p>If the character indicated by <var data-x="">position</var> is a U+002E FULL STOP character
+    (.):</p>
+
+    <ol>
+
+     <li><p>Advance <var data-x="">position</var> to the next character.</p></li>
+
+     <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, or if the
+     character indicated by <var data-x="">position</var> is not an <span data-x="ASCII digits">ASCII
+     digit</span>, then return <var data-x="">value</var> as a length.</li>
+
+     <li><p>Let <var data-x="">divisor</var> have the value 1.</p></li>
+
+     <li><p><i>Fraction loop</i>: Multiply <var data-x="">divisor</var> by ten.</p></li>
+
+     <li>Add the value of the character indicated by <var data-x="">position</var>, interpreted as a
+     base-ten digit (0..9) and divided by <var data-x="">divisor</var>, to <var
+     data-x="">value</var>.</li>
+
+     <li><p>Advance <var data-x="">position</var> to the next character.</p></li>
+
+     <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, then
+     return <var data-x="">value</var> as a length.</li>
+
+     <li><p>If the character indicated by <var data-x="">position</var> is an <span data-x="ASCII
+     digits">ASCII digit</span>, return to the step labeled <i>fraction loop</i> in these
+     substeps.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, return <var
+   data-x="">value</var> as a length.</p></li>
+
+   <li><p>If the character indicated by <var data-x="">position</var> is a U+0025 PERCENT SIGN
+   character (%), return <var data-x="">value</var> as a percentage.</p></li>
+
+   <li><p>Return <var data-x="">value</var> as a length.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h5>Lists of integers</h5>
+
+  <p>A <dfn>valid list of integers</dfn> is a number of <span data-x="valid integer">valid
+  integers</span> separated by U+002C COMMA characters, with no other characters (e.g. no <span
+  data-x="space character">space characters</span>). In addition, there might be restrictions on the
+  number of integers that can be given, or on the range of values allowed.</p>
+
+  <div class="nodev">
+
+  <p>The <dfn>rules for parsing a list of integers</dfn> are as follows:</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p>Let <var data-x="">numbers</var> be an initially empty list of integers. This list will be
+   the result of this algorithm.</p></li>
+
+   <li><p>If there is a character in the string <var data-x="">input</var> at position <var
+   data-x="">position</var>, and it is either a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON
+   character, then advance <var data-x="">position</var> to the next character in <var
+   data-x="">input</var>, or to beyond the end of the string if there are no more
+   characters.</p></li>
+
+   <li><p>If <var data-x="">position</var> points to beyond the end of <var data-x="">input</var>,
+   return <var data-x="">numbers</var> and abort.</p></li>
+
+   <li><p>If the character in the string <var data-x="">input</var> at position <var
+   data-x="">position</var> is a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON character, then
+   return to step 4.</li>
+
+   <li><p>Let <var data-x="">negated</var> be false.</p></li> <li><p>Let <var data-x="">value</var> be
+   0.</p></li>
+
+   <li><p>Let <var data-x="">started</var> be false. This variable is set to true when the parser
+   sees a number or a U+002D HYPHEN-MINUS character (-).</p></li>
+
+   <li><p>Let <var data-x="">got number</var> be false. This variable is set to true when the parser
+   sees a number.</p></li>
+
+   <li><p>Let <var data-x="">finished</var> be false. This variable is set to true to switch parser
+   into a mode where it ignores characters until the next separator.</p></li>
+
+   <li><p>Let <var data-x="">bogus</var> be false.</p></li>
+
+   <li><p><i>Parser</i>: If the character in the string <var data-x="">input</var> at position <var
+   data-x="">position</var> is:</p>
+
+    <dl class="switch">
+
+     <dt>A U+002D HYPHEN-MINUS character</dt>
+
+     <dd>
+
+      <p>Follow these substeps:</p>
+
+      <ol>
+
+       <li>If <var data-x="">got number</var> is true, let <var data-x="">finished</var> be true.</li>
+
+       <li>If <var data-x="">finished</var> is true, skip to the next step in the overall set of
+       steps.</li>
+
+       <li>If <var data-x="">started</var> is true, let <var data-x="">negated</var> be false.</li>
+
+       <li>Otherwise, if <var data-x="">started</var> is false and if <var data-x="">bogus</var> is
+       false, let <var data-x="">negated</var> be true.</li>
+
+       <li>Let <var data-x="">started</var> be true.</li>
+
+      </ol>
+
+     </dd>
+
+     <dt>An <span data-x="ASCII digits">ASCII digit</span></dt>
+
+     <dd>
+
+      <p>Follow these substeps:</p>
+
+      <ol>
+
+       <li>If <var data-x="">finished</var> is true, skip to the next step in the overall set of
+       steps.</li>
+
+       <li>Multiply <var data-x="">value</var> by ten.</li>
+
+       <li>Add the value of the digit, interpreted in base ten, to <var data-x="">value</var>.</li>
+
+       <li>Let <var data-x="">started</var> be true.</li>
+
+       <li>Let <var data-x="">got number</var> be true.</li>
+
+      </ol>
+
+     </dd>
+
+
+     <dt>A U+0020 SPACE character</dt>
+     <dt>A U+002C COMMA character</dt>
+     <dt>A U+003B SEMICOLON character</dt>
+
+     <dd>
+
+      <p>Follow these substeps:</p>
+
+      <ol>
+
+       <li>If <var data-x="">got number</var> is false, return the <var data-x="">numbers</var> list
+       and abort. This happens if an entry in the list has no digits, as in "<code
+       data-x="">1,2,x,4</code>".</li>
+
+       <li>If <var data-x="">negated</var> is true, then negate <var data-x="">value</var>.</li>
+
+       <li>Append <var data-x="">value</var> to the <var data-x="">numbers</var> list.</li>
+
+       <li>Jump to step 4 in the overall set of steps.</li>
+
+      </ol>
+
+     </dd>
+
+
+     <!-- <dt>A U+002E FULL STOP character</dt> -->
+     <dt>A character in the range U+0001 to U+001F, <!-- space --> U+0021 to U+002B, <!-- comma --> U+002D to U+002F, <!-- digits --> U+003A, <!-- semicolon --> U+003C to U+0040, <!-- a-z --> U+005B to U+0060, <!-- A-Z --> U+007b to U+007F
+        (i.e. any other non-alphabetic ASCII character)</dt>
+
+ <!--
+ Test: http://www.hixie.ch/tests/adhoc/html/flow/image-maps/004-demo.html
+ IE6 on Wine treats the following characters like this also: U+1-U+1f, U+21-U+2b, U+2d-U+2f, U+3a,
+ U+3c-U+40, U+5b-U+60, U+7b-U+82, U+84-U+89, U+8b, U+8d, U+8f-U+99, U+9b, U+9d, U+a0-U+bf, U+d7,
+ U+f7, U+1f6-U+1f9, U+218-U+24f, U+2a9-U+385, U+387, U+38b, U+38d, U+3a2, U+3cf, U+3d7-U+3d9, U+3db,
+ U+3dd, U+3df, U+3e1, U+3f4-U+400, U+40d, U+450, U+45d, U+482-U+48f, U+4c5-U+4c6, U+4c9-U+4ca,
+ U+4cd-U+4cf, U+4ec-U+4ed, U+4f6-U+4f7, U+4fa-U+530, U+557-U+560, U+588-U+5cf, U+5eb-U+5ef,
+ U+5f3-U+620, U+63b-U+640, U+64b-U+670, U+6b8-U+6b9, U+6bf, U+6cf, U+6d4, U+6d6-U+904, U+93a-U+957,
+ U+962-U+984, U+98d-U+98e, U+991-U+992, U+9a9, U+9b1, U+9b3-U+9b5, U+9ba-U+9db, U+9de, U+9e2-U+9ef,
+ U+9f2-U+a04, U+a0b-U+a0e, U+a11-U+a12, U+a29, U+a31, U+a34, U+a37, U+a3a-U+a58, U+a5d, U+a5f-U+a84,
+ U+a8c, U+a8e, U+a92, U+aa9, U+ab1, U+ab4, U+aba-U+adf, U+ae1-U+b04, U+b0d-U+b0e, U+b11-U+b12,
+ U+b29, U+b31, U+b34-U+b35, U+b3a-U+b5b, U+b5e, U+b62-U+b84, U+b8b-U+b8d, U+b91, U+b96-U+b98, U+b9b,
+ U+b9d, U+ba0-U+ba2, U+ba5-U+ba7, U+bab-U+bad, U+bb6, U+bba-U+c04, U+c0d, U+c11, U+c29, U+c34,
+ U+c3a-U+c5f, U+c62-U+c84, U+c8d, U+c91, U+ca9, U+cb4, U+cba-U+cdd, U+cdf, U+ce2-U+d04, U+d0d,
+ U+d11, U+d29, U+d3a-U+d5f, U+d62-U+e00, U+e2f, U+e31, U+e34-U+e3f, U+e46-U+e80, U+e83, U+e85-U+e86,
+ U+e89, U+e8b-U+e8c, U+e8e-U+e93, U+e98, U+ea0, U+ea4, U+ea6, U+ea8-U+ea9, U+eac, U+eaf-U+edb,
+ U+ede-U+109f, U+10c6-U+10cf, U+10f7-U+10ff, U+115a-U+115e, U+11a3-U+11a7, U+11fa-U+1dff,
+ U+1e9b-U+1e9f, U+1efa-U+1eff, U+1f16-U+1f17, U+1f1e-U+1f1f, U+1f46-U+1f47, U+1f4e-U+1f4f, U+1f58,
+ U+1f5a, U+1f5c, U+1f5e, U+1f7e-U+1f7f, U+1fb5, U+1fbd-U+1fc1, U+1fc5, U+1fcd-U+1fcf, U+1fd4-U+1fd5,
+ U+1fdc-U+1fdf, U+1fed-U+1ff1, U+1ff5, U+1ffd-U+249b, U+24ea-U+3004, U+3006-U+3040, U+3095-U+309a,
+ U+309f-U+30a0, U+30fb, U+30ff-U+3104, U+312d-U+3130, U+318f-U+4dff, U+9fa6-U+abff, U+d7a4-U+d7ff,
+ U+e000-U+f8ff, U+fa2e-U+faff, U+fb07-U+fb12, U+fb18-U+fb1e, U+fb37, U+fb3d, U+fb3f, U+fb42, U+fb45,
+ U+fbb2-U+fbd2, U+fbe9, U+fce1, U+fd3e-U+fd4f, U+fd90-U+fd91, U+fdc8-U+fdef, U+fdfc-U+fe7f,
+ U+fefd-U+ff20, U+ff3b-U+ff40, U+ff5b-U+ff65, U+ffa0, U+ffbf-U+ffc1, U+ffc8-U+ffc9, U+ffd0-U+ffd1,
+ U+ffd8-U+ffd9, U+ffdd-U+ffff
+ IE7 on Win2003 treats the following characters like this also instead: U+1-U+1f, U+21-U+2b,
+ U+2d-U+2f, U+3a, U+3c-U+40, U+5b-U+60, U+7b-U+82, U+84-U+89, U+8b, U+8d, U+8f-U+99, U+9b, U+9d,
+ U+a0-U+a9, U+ab-U+b4, U+b6-U+b9, U+bb-U+bf, U+d7, U+f7, U+220-U+221, U+234-U+24f, U+2ae-U+2af,
+ U+2b9-U+2ba, U+2c2-U+2df, U+2e5-U+2ed, U+2ef-U+344, U+346-U+379, U+37b-U+385, U+387, U+38b, U+38d,
+ U+3a2, U+3cf, U+3d8-U+3d9, U+3f4-U+3ff, U+482-U+48b, U+4c5-U+4c6, U+4c9-U+4ca, U+4cd-U+4cf,
+ U+4f6-U+4f7, U+4fa-U+530, U+557-U+558, U+55a-U+560, U+588-U+5cf, U+5eb-U+5ef, U+5f3-U+620,
+ U+63b-U+640, U+656-U+66f, U+6d4, U+6dd-U+6e0, U+6e9-U+6ec, U+6ee-U+6f9, U+6fd-U+70f, U+72d-U+72f,
+ U+740-U+77f, U+7b1-U+900, U+904, U+93a-U+93c, U+94d - U+94f, U+951-U+957, U+964-U+980, U+984,
+ U+98d-U+98e, U+991-U+992, U+9a9, U+9b1, U+9b3-U+9b5, U+9ba-U+9bd, U+9c5-U+9c6, U+9c9-U+9ca,
+ U+9cd-U+9d6, U+9d8-U+9db, U+9de, U+9e4-U+9ef, U+9f2-U+a01, U+a03-U+a04, U+a0b-U+a0e, U+a11-U+a12,
+ U+a29, U+a31, U+a34, U+a37, U+a3a-U+a3d, U+a43-U+a46, U+a49-U+a4a, U+a4d-U+a58, U+a5d, U+a5f-U+a6f,
+ U+a75-U+a80, U+a84, U+a8c, U+a8e, U+a92, U+aa9, U+ab1, U+ab4, U+aba-U+abc, U+ac6, U+aca,
+ U+acd-U+acf, U+ad1-U+adf, U+ae1-U+b00, U+b04, U+b0d-U+b0e, U+b11-U+b12, U+b29, U+b31, U+b34-U+b35,
+ U+b3a-U+b3c, U+b44-U+b46, U+b49 - U+b4a, U+b4d-U+b55, U+b58-U+b5b, U+b5e, U+b62-U+b81, U+b84,
+ U+b8b-U+b8d, U+b91, U+b96-U+b98, U+b9b, U+b9d, U+ba0 - U+ba2, U+ba5-U+ba7, U+bab-U+bad, U+bb6,
+ U+bba-U+bbd, U+bc3-U+bc5, U+bc9, U+bcd-U+bd6, U+bd8-U+c00, U+c04, U+c0d, U+c11, U+c29, U+c34,
+ U+c3a-U+c3d, U+c45, U+c49, U+c4d-U+c54, U+c57-U+c5f, U+c62-U+c81, U+c84, U+c8d, U+c91, U+ca9,
+ U+cb4, U+cba-U+cbd, U+cc5, U+cc9, U+ccd-U+cd4, U+cd7-U+cdd, U+cdf, U+ce2-U+d01, U+d04, U+d0d,
+ U+d11, U+d29, U+d3a-U+d3d, U+d44-U+d45, U+d49, U+d4d-U+d56, U+d58-U+d5f, U+d62-U+d81, U+d84,
+ U+d97-U+d99, U+db2, U+dbc, U+dbe - U+dbf, U+dc7-U+dce, U+dd5, U+dd7, U+de0-U+df1, U+df4-U+e00,
+ U+e3b-U+e3f, U+e4f-U+e80, U+e83, U+e85-U+e86, U+e89, U+e8b-U+e8c, U+e8e-U+e93, U+e98, U+ea0, U+ea4,
+ U+ea6, U+ea8-U+ea9, U+eac, U+eba, U+ebe-U+ebf, U+ec5-U+ecc, U+ece-U+edb, U+ede-U+eff, U+f01-U+f3f,
+ U+f48, U+f6b-U+f70, U+f82-U+f87, U+f8c-U+f8f, U+f98, U+fbd-U+fff, U+1022, U+1028, U+102b,
+ U+1033-U+1035, U+1037, U+1039-U+104f, U+105a-U+109f, U+10c6-U+10cf, U+10f7-U+10ff, U+115a - U+115e,
+ U+11a3-U+11a7, U+11fa-U+11ff, U+1207, U+1247, U+1249, U+124e-U+124f, U+1257, U+1259, U+125e-U+125f,
+ U+1287, U+1289, U+128e-U+128f, U+12af, U+12b1, U+12b6-U+12b7, U+12bf, U+12c1, U+12c6-U+12c7,
+ U+12cf, U+12d7, U+12ef, U+130f, U+1311, U+1316-U+1317, U+131f, U+1347, U+135b-U+139f,
+ U+13f5-U+1400, U+166d-U+166e, U+1677-U+1680, U+169b - U+169f, U+16eb-U+177f, U+17c9-U+181f, U+1843,
+ U+1878-U+187f, U+18aa-U+1dff, U+1e9c-U+1e9f, U+1efa-U+1eff, U+1f16-U+1f17, U+1f1e-U+1f1f,
+ U+1f46-U+1f47, U+1f4e-U+1f4f, U+1f58, U+1f5a, U+1f5c, U+1f5e, U+1f7e-U+1f7f, U+1fb5, U+1fbd,
+ U+1fbf-U+1fc1, U+1fc5, U+1fcd-U+1fcf, U+1fd4-U+1fd5, U+1fdc-U+1fdf, U+1fed-U+1ff1, U+1ff5,
+ U+1ffd-U+207e, U+2080-U+2101, U+2103-U+2106, U+2108-U+2109, U+2114, U+2116-U+2118, U+211e-U+2123,
+ U+2125, U+2127, U+2129, U+212e, U+2132, U+213a-U+215f, U+2184-U+3005, U+3008-U+3020, U+302a-U+3037,
+ U+303b-U+3104, U+312d-U+3130, U+318f - U+319f, U+31b8-U+33ff, U+4db6-U+4dff, U+9fa6-U+9fff,
+ U+a48d-U+abff, U+d7a4-U+d7ff, U+e000-U+f8ff, U+fa2e-U+faff, U+fb07-U+fb12, U+fb18-U+fb1c, U+fb1e,
+ U+fb29, U+fb37, U+fb3d, U+fb3f, U+fb42, U+fb45, U+fbb2-U+fbd2, U+fd3e-U+fd4f, U+fd90-U+fd91,
+ U+fdc8-U+fdef, U+fdfc-U+fe6f, U+fe73, U+fe75, U+fefd-U+ff20, U+ff3b-U+ff40, U+ff5b-U+ff9f,
+ U+ffbf-U+ffc1, U+ffc8-U+ffc9, U+ffd0-U+ffd1, U+ffd8-U+ffd9, U+ffdd-U+ffff
+-->
+
+     <dd>
+
+      <p>Follow these substeps:</p>
+
+      <ol>
+
+       <li>If <var data-x="">got number</var> is true, let <var data-x="">finished</var> be true.</li>
+
+       <li>If <var data-x="">finished</var> is true, skip to the next step in the overall set of
+       steps.</li>
+
+       <li>Let <var data-x="">negated</var> be false.</li>
+
+      </ol>
+
+     </dd>
+
+
+     <dt>Any other character</dt>
+     <!-- alphabetic a-z A-Z, and non-ASCII -->
+
+     <dd>
+
+      <p>Follow these substeps:</p>
+
+      <ol>
+
+       <li>If <var data-x="">finished</var> is true, skip to the next step in the overall set of
+       steps.</li>
+
+       <li>Let <var data-x="">negated</var> be false.</li>
+
+       <li>Let <var data-x="">bogus</var> be true.</li>
+
+       <li>If <var data-x="">started</var> is true, then return the <var data-x="">numbers</var> list,
+       and abort. (The value in <var data-x="">value</var> is not appended to the list first; it is
+       dropped.)</li>
+
+      </ol>
+
+     </dd>
+
+    </dl>
+
+   </li>
+
+   <li><p>Advance <var data-x="">position</var> to the next character in <var data-x="">input</var>,
+   or to beyond the end of the string if there are no more characters.</p></li>
+
+   <li><p>If <var data-x="">position</var> points to a character (and not to beyond the end of <var
+   data-x="">input</var>), jump to the big <i>Parser</i> step above.</p></li>
+
+   <li><p>If <var data-x="">negated</var> is true, then negate <var data-x="">value</var>.</li>
+
+   <li><p>If <var data-x="">got number</var> is true, then append <var data-x="">value</var> to the
+   <var data-x="">numbers</var> list.</li>
+
+   <li><p>Return the <var data-x="">numbers</var> list and abort.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <div class="nodev">
+
+  <h5>Lists of dimensions</h5>
+
+  <!-- no definition of a type since no conforming feature uses this syntax (it's only used in
+  cols="" and rows="" on <frameset> elements -->
+
+  <p>The <dfn>rules for parsing a list of dimensions</dfn> 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 <i>percentage</i>,
+  <i>relative</i>, and <i>absolute</i>.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">raw input</var> be the string being parsed.</p></li>
+
+   <li><p>If the last character in <var data-x="">raw input</var> is a U+002C COMMA character (,),
+   then remove that character from <var data-x="">raw input</var>.</p></li>
+
+   <li><p><span data-x="split a string on commas">Split the string <var data-x="">raw input</var> on
+   commas</span>. Let <var data-x="">raw tokens</var> be the resulting list of tokens.</p></li>
+
+   <li><p>Let <var data-x="">result</var> be an empty list of number/unit pairs.</p></li>
+
+   <li>
+
+    <p>For each token in <var data-x="">raw tokens</var>, run the following substeps:</p>
+
+    <ol>
+
+     <li><p>Let <var data-x="">input</var> be the token.</p></li>
+
+     <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>,
+     initially pointing at the start of the string.</p></li>
+
+     <li><p>Let <var data-x="">value</var> be the number 0.</p></li>
+
+     <li><p>Let <var data-x="">unit</var> be <i>absolute</i>.</p></li>
+
+     <li><p>If <var data-x="">position</var> is past the end of <var data-x="">input</var>, set <var
+     data-x="">unit</var> to <i>relative</i> and jump to the last substep.</p></li>
+
+     <li><p>If the character at <var data-x="">position</var> is an <span data-x="ASCII
+     digits">ASCII digit</span>, <span>collect a sequence of characters</span> that are <span>ASCII
+     digits</span>, interpret the resulting sequence as an integer in base ten, and increment <var
+     data-x="">value</var> by that integer.</p></li>
+
+     <li>
+
+      <p>If the character at <var data-x="">position</var> is a U+002E FULL STOP character (.), run
+      these substeps:</p>
+
+      <ol>
+
+       <li><p><span>Collect a sequence of characters</span> consisting of <span data-x="space
+       character">space characters</span> and <span>ASCII digits</span>. Let <var data-x="">s</var>
+       be the resulting sequence.</p></li>
+
+       <li><p>Remove all <span data-x="space character">space characters</span> in <var
+       data-x="">s</var>.</p></li>
+
+       <li>
+
+        <p>If <var data-x="">s</var> is not the empty string, run these subsubsteps:</p>
+
+        <ol>
+
+         <li><p>Let <var data-x="">length</var> be the number of characters in <var
+         data-x="">s</var> (after the spaces were removed).</p></li>
+
+         <li><p>Let <var data-x="">fraction</var> be the result of interpreting <var
+         data-x="">s</var> as a base-ten integer, and then dividing that number by <span
+         data-x="">10<sup data-x=""><var data-x="">length</var></sup></span>.</li>
+
+         <li><p>Increment <var data-x="">value</var> by <var data-x="">fraction</var>.</p></li>
+
+        </ol>
+
+       </li>
+
+      </ol>
+
+     </li>
+
+     <li><p><span>Skip whitespace</span>.</p></li>
+
+     <li>
+
+      <p>If the character at <var data-x="">position</var> is a U+0025 PERCENT SIGN character (%),
+      then set <var data-x="">unit</var> to <i>percentage</i>.</p>
+
+      <p>Otherwise, if the character at <var data-x="">position</var> is a U+002A ASTERISK character
+      (*), then set <var data-x="">unit</var> to <i>relative</i>.</p>
+
+     </li>
+
+     <!-- the remaining characters in /input/ are ignored -->
+
+     <li><p>Add an entry to <var data-x="">result</var> consisting of the number given by <var
+     data-x="">value</var> and the unit given by <var data-x="">unit</var>.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Return the list <var data-x="">result</var>.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h4>Dates and times</h4>
+
+  <p>In the algorithms below, the <dfn>number of days in month <var data-x="">month</var> of year
+  <var data-x="">year</var></dfn> is: <em>31</em> if <var data-x="">month</var> is 1, 3, 5, 7, 8,
+  10, or 12; <em>30</em> if <var data-x="">month</var> is 4, 6, 9, or 11; <em>29</em> if <var
+  data-x="">month</var> is 2 and <var data-x="">year</var> is a number divisible by 400, or if <var
+  data-x="">year</var> is a number divisible by 4 but not by 100; and <em>28</em> otherwise. This
+  takes into account leap years in the Gregorian calendar. <a
+  href="#refsGREGORIAN">[GREGORIAN]</a></p>
+
+  <p>When <span>ASCII digits</span> are used in the date and time syntaxes defined in this section,
+  they express numbers in base ten.</p>
+
+  <div class="nodev">
+
+  <p class="note">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. <a href="#refsISO8601">[ISO8601]</a></p>
+
+  </div>
+
+  <p>Where this specification refers to the <dfn>proleptic Gregorian calendar</dfn>, it means the
+  modern Gregorian calendar, extrapolated backwards to year 1. A date in the <span>proleptic
+  Gregorian calendar</span>, sometimes explicitly referred to as a <dfn>proleptic-Gregorian
+  date</dfn>, is one that is described using that calendar even if that calendar was not in use at
+  the time (or place) in question. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>
+
+  <p class="note">The use of the Gregorian calendar as the wire format in this specification is an
+  arbitrary choice resulting from the cultural biases of those involved in the decision. See also
+  the section discussing <a href="#input-author-notes">date, time, and number formats</a> in forms
+  <span class="nodev">(for authors), <a href="#input-impl-notes">implemention notes regarding
+  localization of form controls</a>,</span> and the <code>time</code> element.</p>
+
+
+  <h5>Months</h5>
+
+  <p>A <dfn data-x="concept-month">month</dfn> consists of a specific <span>proleptic-Gregorian
+  date</span> with no time-zone information and no date information beyond a year and a month. <a
+  href="#refsGREGORIAN">[GREGORIAN]</a></p>
+
+  <p>A string is a <dfn>valid month string</dfn> representing a year <var data-x="">year</var> and
+  month <var data-x="">month</var> if it consists of the following components in the given order:</p>
+
+  <ol>
+
+   <li>Four or more <span>ASCII digits</span>, representing <var data-x="">year</var>, where <var
+   data-x="">year</var>&nbsp;&gt;&nbsp;0</li>
+
+   <li>A U+002D HYPHEN-MINUS character (-)</li>
+
+   <li>Two <span>ASCII digits</span>, representing the month <var data-x="">month</var>, in the range
+   1&nbsp;&le;&nbsp;<var data-x="">month</var>&nbsp;&le;&nbsp;12</li>
+
+  </ol>
+
+  <div class="nodev">
+
+  <p>The rules to <dfn>parse a month string</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p><span>Parse a month component</span> to obtain <var data-x="">year</var> and <var
+   data-x="">month</var>. If this returns nothing, then fail.</p>
+
+   <li><p>If <var data-x="">position</var> is <em>not</em> beyond the
+   end of <var data-x="">input</var>, then fail.</p></li>
+
+   <li><p>Return <var data-x="">year</var> and <var data-x="">month</var>.</p></li>
+
+  </ol>
+
+  <p>The rules to <dfn>parse a month component</dfn>, given an <var data-x="">input</var> string and
+  a <var data-x="">position</var>, 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.</p>
+
+  <ol>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">year</var>.</p></li>
+
+   <li><p>If <var data-x="">year</var> is not a number greater than zero, then fail.</p></li>
+
+   <li><p>If <var data-x="">position</var> is beyond the end of <var data-x="">input</var> or if the
+   character at <var data-x="">position</var> is not a U+002D HYPHEN-MINUS character, then fail.
+   Otherwise, move <var data-x="">position</var> forwards one character.</p></li>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">month</var>.</p></li>
+
+   <li><p>If <var data-x="">month</var> is not a number in the range 1&nbsp;&le;&nbsp;<var
+   data-x="">month</var>&nbsp;&le;&nbsp;12, then fail.</p></li>
+
+   <li><p>Return <var data-x="">year</var> and <var data-x="">month</var>.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h5>Dates</h5>
+
+  <p>A <dfn data-x="concept-date">date</dfn> consists of a specific <span>proleptic-Gregorian
+  date</span> with no time-zone information, consisting of a year, a month, and a day. <a
+  href="#refsGREGORIAN">[GREGORIAN]</a></p>
+
+  <p>A string is a <dfn>valid date string</dfn> representing a year <var data-x="">year</var>, month
+  <var data-x="">month</var>, and day <var data-x="">day</var> if it consists of the following
+  components in the given order:</p>
+
+  <ol>
+
+   <li>A <span>valid month string</span>, representing <var data-x="">year</var> and <var
+   data-x="">month</var></li>
+
+   <li>A U+002D HYPHEN-MINUS character (-)</li>
+
+   <li>Two <span>ASCII digits</span>, representing <var data-x="">day</var>, in the range
+   1&nbsp;&le;&nbsp;<var data-x="">day</var>&nbsp;&le;&nbsp;<var data-x="">maxday</var> where <var
+   data-x="">maxday</var> is the <span data-x="number of days in month month of year year">number of
+   days in the month <var data-x="">month</var> and year <var data-x="">year</var></span></li>
+
+  </ol>
+
+  <div class="nodev">
+
+  <p>The rules to <dfn>parse a date string</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p><span>Parse a date component</span> to obtain <var data-x="">year</var>, <var
+   data-x="">month</var>, and <var data-x="">day</var>. If this returns nothing, then fail.</p>
+
+   <li><p>If <var data-x="">position</var> is <em>not</em> beyond the end of <var
+   data-x="">input</var>, then fail.</p></li>
+
+   <li><p>Let <var data-x="">date</var> be the date with year <var data-x="">year</var>, month <var
+   data-x="">month</var>, and day <var data-x="">day</var>.</p></li>
+
+   <li><p>Return <var data-x="">date</var>.</p></li>
+
+  </ol>
+
+  <p>The rules to <dfn>parse a date component</dfn>, given an <var data-x="">input</var> string and a
+  <var data-x="">position</var>, 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.</p>
+
+  <ol>
+
+   <li><p><span>Parse a month component</span> to obtain <var data-x="">year</var> and <var
+   data-x="">month</var>. If this returns nothing, then fail.</li>
+
+   <li><p>Let <var data-x="">maxday</var> be the <span>number of days in month <var
+   data-x="">month</var> of year <var data-x="">year</var></span>.</p></li>
+
+   <li><p>If <var data-x="">position</var> is beyond the end of <var data-x="">input</var> or if the
+   character at <var data-x="">position</var> is not a U+002D HYPHEN-MINUS character, then fail.
+   Otherwise, move <var data-x="">position</var> forwards one character.</p></li>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">day</var>.</p></li>
+
+   <li><p>If <var data-x="">day</var> is not a number in the range 1&nbsp;&le;&nbsp;<var
+   data-x="">day</var>&nbsp;&le;&nbsp;<var data-x="">maxday</var>, then fail.</li>
+
+   <li><p>Return <var data-x="">year</var>, <var data-x="">month</var>, and <var
+   data-x="">day</var>.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h5>Yearless dates</h5>
+
+  <p>A <dfn data-x="concept-yearless-date">yearless date</dfn> consists of a Gregorian month and a
+  day within that month, but with no associated year. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>
+
+  <p>A string is a <dfn>valid yearless date string</dfn> representing a month <var
+  data-x="">month</var> and a day <var data-x="">day</var> if it consists of the following components
+  in the given order:</p>
+
+  <ol>
+
+   <li>Optionally, two U+002D HYPHEN-MINUS characters (-)</li>
+
+   <li>Two <span>ASCII digits</span>, representing the month <var data-x="">month</var>, in the range
+   1&nbsp;&le;&nbsp;<var data-x="">month</var>&nbsp;&le;&nbsp;12</li>
+
+   <li>A U+002D HYPHEN-MINUS character (-)</li>
+
+   <li>Two <span>ASCII digits</span>, representing <var data-x="">day</var>, in the range
+   1&nbsp;&le;&nbsp;<var data-x="">day</var>&nbsp;&le;&nbsp;<var data-x="">maxday</var> where <var
+   data-x="">maxday</var> is the <span data-x="number of days in month month of year year">number of
+   days</span> in the month <var data-x="">month</var> and any arbitrary leap year (e.g. 4 or
+   2000)</li>
+
+  </ol>
+
+  <p class="note">In other words, if the <var data-x="">month</var> is "<code data-x="">02</code>",
+  meaning February, then the day can be 29, as if the year was a leap year.</p>
+
+  <div class="nodev">
+
+  <p>The rules to <dfn>parse a yearless date string</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p><span>Parse a yearless date component</span> to obtain <var data-x="">month</var> and <var
+   data-x="">day</var>. If this returns nothing, then fail.</p>
+
+   <li><p>If <var data-x="">position</var> is <em>not</em> beyond the end of <var
+   data-x="">input</var>, then fail.</p></li>
+
+   <li><p>Return <var data-x="">month</var> and <var data-x="">day</var>.</p></li>
+
+  </ol>
+
+  <p>The rules to <dfn>parse a yearless date component</dfn>, given an <var data-x="">input</var>
+  string and a <var data-x="">position</var>, 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.</p>
+
+  <ol>
+
+   <li><p><span>Collect a sequence of characters</span> that are U+002D HYPHEN-MINUS characters (-).
+   If the collected sequence is not exactly zero or two characters long, then fail.</p></li>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">month</var>.</p></li>
+
+   <li><p>If <var data-x="">month</var> is not a number in the range 1&nbsp;&le;&nbsp;<var
+   data-x="">month</var>&nbsp;&le;&nbsp;12, then fail.</p></li>
+
+   <li><p>Let <var data-x="">maxday</var> be the <span data-x="number of days in month month of year
+   year">number of days</span> in month <var data-x="">month</var> of any arbitrary leap year (e.g. 4
+   or 2000).</p></li>
+
+   <li><p>If <var data-x="">position</var> is beyond the end of <var data-x="">input</var> or if the
+   character at <var data-x="">position</var> is not a U+002D HYPHEN-MINUS character, then fail.
+   Otherwise, move <var data-x="">position</var> forwards one character.</p></li>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">day</var>.</p></li>
+
+   <li><p>If <var data-x="">day</var> is not a number in the range 1&nbsp;&le;&nbsp;<var
+   data-x="">day</var>&nbsp;&le;&nbsp;<var data-x="">maxday</var>, then fail.</li>
+
+   <li><p>Return <var data-x="">month</var> and <var data-x="">day</var>.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h5>Times</h5>
+
+  <p>A <dfn data-x="concept-time">time</dfn> consists of a specific time with no time-zone
+  information, consisting of an hour, a minute, a second, and a fraction of a second.</p>
+
+  <p>A string is a <dfn>valid time string</dfn> representing an hour <var data-x="">hour</var>, a
+  minute <var data-x="">minute</var>, and a second <var data-x="">second</var> if it consists of the
+  following components in the given order:</p>
+
+  <ol>
+
+   <li>Two <span>ASCII digits</span>, representing <var data-x="">hour</var>, in the range
+   0&nbsp;&le;&nbsp;<var data-x="">hour</var>&nbsp;&le;&nbsp;23</li>
+
+   <li>A U+003A COLON character (:)</li>
+
+   <li>Two <span>ASCII digits</span>, representing <var data-x="">minute</var>, in the range
+   0&nbsp;&le;&nbsp;<var data-x="">minute</var>&nbsp;&le;&nbsp;59</li>
+
+   <li>If <var data-x="">second</var> is non-zero, or optionally if <var data-x="">second</var> is
+   zero:
+
+    <ol>
+
+     <li>A U+003A COLON character (:)</li>
+
+     <li>Two <span>ASCII digits</span>, representing the integer part of <var data-x="">second</var>,
+     in the range 0&nbsp;&le;&nbsp;<var data-x="">s</var>&nbsp;&le;&nbsp;59</li>
+
+     <li>If <var data-x="">second</var> is not an integer, or optionally if <var
+     data-x="">second</var> is an integer:
+
+      <ol>
+
+       <li>A 002E FULL STOP character (.)</li>
+
+       <li>One, two, or three <span>ASCII digits</span>, representing the fractional part of <var
+       data-x="">second</var></li>
+
+      </ol>
+
+     </li>
+
+    </ol>
+
+   </li>
+
+  </ol>
+
+  <p class="note">The <var data-x="">second</var> component cannot be 60 or 61; leap seconds cannot
+  be represented.</p>
+
+  <div class="nodev">
+
+  <p>The rules to <dfn>parse a time string</dfn> 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.</p>
+
+  <ol>
+
+   <li><p>Let <var data-x="">input</var> be the string being parsed.</p></li>
+
+   <li><p>Let <var data-x="">position</var> be a pointer into <var data-x="">input</var>, initially
+   pointing at the start of the string.</p></li>
+
+   <li><p><span>Parse a time component</span> to obtain <var data-x="">hour</var>, <var
+   data-x="">minute</var>, and <var data-x="">second</var>. If this returns nothing, then fail.</p>
+
+   <li><p>If <var data-x="">position</var> is <em>not</em> beyond the end of <var
+   data-x="">input</var>, then fail.</p></li>
+
+   <li><p>Let <var data-x="">time</var> be the time with hour <var data-x="">hour</var>, minute <var
+   data-x="">minute</var>, and second <var data-x="">second</var>.</p></li>
+
+   <li><p>Return <var data-x="">time</var>.</p></li>
+
+  </ol>
+
+  <p>The rules to <dfn>parse a time component</dfn>, given an <var data-x="">input</var> string and a
+  <var data-x="">position</var>, 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.</p>
+
+  <ol>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">hour</var>.</p></li>
+
+   <li>If <var data-x="">hour</var> is not a number in the range 0&nbsp;&le;&nbsp;<var
+   data-x="">hour</var>&nbsp;&le;&nbsp;23, then fail.</li>
+
+   <li><p>If <var data-x="">position</var> is beyond the end of <var data-x="">input</var> or if the
+   character at <var data-x="">position</var> is not a U+003A COLON character, then fail. Otherwise,
+   move <var data-x="">position</var> forwards one character.</p></li>
+
+   <li><p><span>Collect a sequence of characters</span> that are <span>ASCII digits</span>. 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 <var
+   data-x="">minute</var>.</p></li>
+
+   <li>If <var data-x="">minute</var> is not a number in the range 0&nbsp;&le;&nbsp;<var
+   data-x="">minute</var>&nbsp;&le;&nbsp;59, then fail.</li>
+
+   <li><p>Let <var data-x="">second</var> be a string with the value "0".</p></li>
+
+   <li>
+
+    <p>If <var data-x="">position</var> is not beyond the end of <var data-x="">input</var> and the
+    character at <var data-x="">position</var> is a U+003A COLON, then run these substeps:</p>
+
+    <ol>
+
+     <li><p>Advance <var data-x="">position</var> to the next character in <var
+     data-x="">input</var>.</p></li>
+
+     <li><p>If <var data-x="">position</var> is beyond the end of <var data-x="">input</var>, or at
+     the last character in <var data-x="">input</var>, or if the next <em>two</em> characters in <var
+     data-x="">input</var> starting at <var data-x="">position</var> are not both <span>ASCII
+     digits</span>, then fail.</p></li>
+
+     <li><p><span>Collect a sequence of characters</span> that are either <span>ASCII digits</span>
+     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 <var data-x="">second</var> instead of its previous value.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Interpret <var data-x="">second</var> as a base-ten number (possibly with a fractional
+   part). Let <var data-x="">second</var> be that number instead of the string version.</p></li>
+
+   <li><p>If <var data-x="">second</var> is not a number in the range 0&nbsp;&le;&nbsp;<var
+   data-x="">second</var>&nbsp;&lt;&nbsp;60, then fail.</p></li>
+
+   <li><p>Return <var data-x="">hour</var>, <var data-x="">minute</var>, and <var
+   data-x="">second</var>.</p></li>
+
+  </ol>
+
+  </div>
+
+
+  <h5>Local dates and times</h5>
+
+  <p>A <dfn data-x="concept-datetime-local">local date and time</dfn> consists of a specific
+  <span>proleptic-Gregorian date</span>, 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. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>
+
+  <p>A string is a <dfn>valid local date and time string</dfn> representing a date and time if it
+  consists of the following components in the given order:</p>
+
+  <ol>
+
+   <li>A <span>valid date string</span> representing the date</li>
+
+   <li>A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character</li>
+
+   <li>A <span>valid time string</span> representing the time</li>
+
+  </ol>
+
+  <p>A string is a <dfn>valid normalised local date and time string</dfn> representing a date and
+  time if it consists of the following components in the given order:</p>
+
+  <ol>
+
+   <li>A <span>valid date string</span> representing the date</li>
+
+   <li>A U+0054 LATIN CAPITAL LETTER T character (T)</li>
+
+   <li>A <span>valid time string</span> 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)</li>
+
+  </ol>
+
+  <div class="nodev">
+
+  <p>The rules to <dfn>parse a local date and time string</dfn> 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 @@
+<!doctype html>
+<title>Accessing named windows from outside the unit of related browsing contexts</title>
+<a href="001-1.html" target="test_name">Click here</a>
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 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Backgrounds and Borders Reference</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<style>
+  div {
+    background-color: green;
+    height: 55px;
+    left: 5px;
+    position: relative;
+    top: 5px;
+    width: 55px;
+  }
+</style>
+<body>
+  <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+  <div></div>
+</body>
diff --git a/benchmarks/data/wpt/random/background_shorthand_css_relative_url.html b/benchmarks/data/wpt/random/background_shorthand_css_relative_url.html
new file mode 100644
index 00000000..2397fec0
--- /dev/null
+++ b/benchmarks/data/wpt/random/background_shorthand_css_relative_url.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<title>WebVTT rendering, ::cue, background shorthand, background image URL with relative path from CSS file</title>
+<link rel="match" href="background_shorthand_css_relative_url-ref.html">
+<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
+<style>
+html { overflow:hidden }
+body { margin:0 }
+::cue {
+    font-family: Ahem, sans-serif;
+    background: #0f0 url('../../media/background.gif') repeat-x top left;
+    color: green;
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<video width="320" height="180" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
+    <source src="/media/white.webm" type="video/webm">
+    <source src="/media/white.mp4" type="video/mp4">
+    <track src="../../support/test.vtt">
+    <script>
+    document.getElementsByTagName('track')[0].track.mode = 'showing';
+    </script>
+</video>
+</html>
diff --git a/benchmarks/data/wpt/random/beforeunload-on-history-back-1.html b/benchmarks/data/wpt/random/beforeunload-on-history-back-1.html
new file mode 100644
index 00000000..4403cfa8
--- /dev/null
+++ b/benchmarks/data/wpt/random/beforeunload-on-history-back-1.html
@@ -0,0 +1,5 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("beforeunload", function() {top.t.step(function() {top.beforeunload_fired = true})}, false);
+</script>
diff --git a/benchmarks/data/wpt/random/euckr-encode-form.html b/benchmarks/data/wpt/random/euckr-encode-form.html
new file mode 100644
index 00000000..545f8ac9
--- /dev/null
+++ b/benchmarks/data/wpt/random/euckr-encode-form.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="euc-kr"> <!-- test breaks if the server overrides this -->
+<title>EUC-KR encoding (form)</title>
+<meta name="timeout" content="long">
+<meta name="variant" content="?1-1000">
+<meta name="variant" content="?1001-2000">
+<meta name="variant" content="?2001-3000">
+<meta name="variant" content="?3001-4000">
+<meta name="variant" content="?4001-5000">
+<meta name="variant" content="?5001-6000">
+<meta name="variant" content="?6001-7000">
+<meta name="variant" content="?7001-8000">
+<meta name="variant" content="?8001-9000">
+<meta name="variant" content="?9001-10000">
+<meta name="variant" content="?10001-11000">
+<meta name="variant" content="?11001-12000">
+<meta name="variant" content="?12001-13000">
+<meta name="variant" content="?13001-14000">
+<meta name="variant" content="?14001-15000">
+<meta name="variant" content="?15001-16000">
+<meta name="variant" content="?16001-17000">
+<meta name="variant" content="?17001-last">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/subset-tests.js"></script>
+<script src="euckr_index.js"></script>
+<script src="euckr-encoder.js"></script>
+<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
+<link rel="help" href="https://encoding.spec.whatwg.org/#euc-kr">
+<meta name="assert" content="The browser produces the expected byte sequences for all characters in the euc-kr encoding after 0x9F when encoding bytes for a URL produced by a form, using the  encoder steps in the specification.">
+<style>
+ iframe { display:none }
+ form { display:none }
+</style>
+</head>
+<body>
+<div id="log"></div>
+<script src="../../resources/ranges.js"></script>
+<script>
+var errors = false;
+var encoder = euckrEncoder;
+var ranges = rangesAll;
+var separator = ",";
+function expect(result, codepoint) {
+  return "%" + result.replace(/ /g, "%");
+}
+</script>
+<script src="../../resources/encode-form-common.js"></script>
+</body>
+</html>
diff --git a/benchmarks/data/wpt/random/frame-ancestors-self-allow.html b/benchmarks/data/wpt/random/frame-ancestors-self-allow.html
new file mode 100644
index 00000000..a8a295df
--- /dev/null
+++ b/benchmarks/data/wpt/random/frame-ancestors-self-allow.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script src="support/frame-ancestors-test.sub.js"></script>
+</head>
+<body>
+    <script>
+        test = async_test("A 'frame-ancestors' CSP directive with a value 'self' should allow rendering.");
+
+        sameOriginFrameShouldBeAllowed("'self'");
+    </script>
+</body>
+</html>
+
diff --git a/benchmarks/data/wpt/random/grouping-dl.html b/benchmarks/data/wpt/random/grouping-dl.html
new file mode 100644
index 00000000..2394d6a9
--- /dev/null
+++ b/benchmarks/data/wpt/random/grouping-dl.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>the dl element</title>
+    <link rel="author" title="dzenana" href="mailto:dzenana.trenutak@gmail.com">
+    <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-dl-element">
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script>
+        "use strict";
+
+        // check that prototype matches spec's DOM interface
+        test(function () {
+            var testElement = document.createElement("dl");
+            assert_equals(Object.getPrototypeOf(testElement), HTMLDListElement.prototype, "HTMLDListElement.prototype should be used for dl");
+        }, "The prototype for dl is HTMLDListElement.prototype");
+
+        // Not checking: effects of markup on defining groups and the name-pair values within those groups
+
+    </script>
+</head>
+<body>
+    <h1>Description</h1>
+    <p>This test validates the dl element.</p>
+
+    <div id="log"></div>
+
+</body>
+</html>
diff --git a/benchmarks/data/wpt/random/heavy-styling-005.html b/benchmarks/data/wpt/random/heavy-styling-005.html
new file mode 100644
index 00000000..2bbdb3cf
--- /dev/null
+++ b/benchmarks/data/wpt/random/heavy-styling-005.html
@@ -0,0 +1,15 @@
+<!DOCTYPe html>
+<meta charset='utf-8'>
+<title>drag and drop â€“Â feedback overlay for heavily styled elements â€“ 005</title>
+<style>
+a {
+  display: block;
+  height: 200px;
+  width: 200px;
+  background-color: rgba(0,0,255,0.5);
+}
+</style>
+
+<p>Drag the blue box below downwards. The drag placeholder should resemble the blue box, including the text within it.</p>
+
+<a draggable="true" ondragstart="event.dataTransfer.effectAllowed ='copy'">TEST</a>
diff --git a/benchmarks/data/wpt/random/htb-ltr-ltr.html b/benchmarks/data/wpt/random/htb-ltr-ltr.html
new file mode 100644
index 00000000..5a19c0e9
--- /dev/null
+++ b/benchmarks/data/wpt/random/htb-ltr-ltr.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css2/visudet.html#abs-non-replaced-width" />
+<link rel="match" href="htb-ref.html">
+<meta name="assert" content="This test checks the static position of an out of flow absolute positioned element, under various conditions." />
+<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
+<style>
+.container {
+  position: relative;
+  background: green;
+  color: green;
+  font: 16px/1 Ahem;
+  border: solid black 3px;
+  width: 400px;
+  margin: 16px 0;
+}
+.red { color: red; }
+.cb { position: relative; }
+.rtl { direction: rtl; }
+.ltr { direction: ltr; }
+.inline { display: inline; }
+.abs { position: absolute; }
+
+.indent { text-indent: 20px; }
+* { text-indent: initial; }
+</style>
+
+There should be no red.
+<div class="container ltr">
+  XXX<span class="ltr">XX<div class="abs inline">XXXXX</div><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr indent">
+  XXX<span class="ltr">XX<div class="abs inline">XXXXX</div><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr">
+  XXX<span class="ltr">XX<div class="abs block">XXXXX</div><br><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr indent">
+  XXX<span class="ltr">XX<div class="abs block">XXXXX</div><br><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr">
+  XXX<span class="ltr cb">XX<div class="abs inline">XXXXX</div><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr indent">
+  XXX<span class="ltr cb">XX<div class="abs inline">XXXXX</div><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr">
+  XXX<span class="ltr cb">XX<div class="abs block">XXXXX</div><br><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr indent">
+  XXX<span class="ltr cb">XX<div class="abs block">XXXXX</div><br><span class="red">XXXXX</span></span>
+</div>
+
+<div class="container ltr">
+  <span class="cb">XXX<span class="ltr">XX<div class="abs inline">XXXXX</div><span class="red">XXXXX</span></span></span>
+</div>
+
+<div class="container ltr indent">
+  <span class="cb">XXX<span class="ltr">XX<div class="abs inline">XXXXX</div><span class="red">XXXXX</span></span></span>
+</div>
+
+<div class="container ltr">
+  <span class="cb">XXX<span class="ltr">XX<div class="abs block">XXXXX</div><br><span class="red">XXXXX</span></span></span>
+</div>
+
+<div class="container ltr indent">
+  <span class="cb">XXX<span class="ltr">XX<div class="abs block">XXXXX</div><br><span class="red">XXXXX</span></span></span>
+</div>
diff --git a/benchmarks/data/wpt/random/idbindex_get8.htm b/benchmarks/data/wpt/random/idbindex_get8.htm
new file mode 100644
index 00000000..9bfc4842
--- /dev/null
+++ b/benchmarks/data/wpt/random/idbindex_get8.htm
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>IDBIndex.get() - throw InvalidStateError on index deleted by aborted upgrade</title>
+<link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idb">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=support.js></script>
+<div id="log"></div>
+<script>
+    var db,
+        t = async_test();
+
+    var open_rq = createdb(t);
+    open_rq.onupgradeneeded = function(e) {
+        db = e.target.result;
+        var store = db.createObjectStore("store", { keyPath: "key" });
+        var index = store.createIndex("index", "indexedProperty");
+        store.add({ key: 1, indexedProperty: "data" });
+
+        e.target.transaction.abort();
+
+        assert_throws_dom("InvalidStateError", function(){
+            index.get("data");
+        });
+        t.done();
+    }
+</script>
diff --git a/benchmarks/data/wpt/random/idlharness.html b/benchmarks/data/wpt/random/idlharness.html
new file mode 100644
index 00000000..ecc601bc
--- /dev/null
+++ b/benchmarks/data/wpt/random/idlharness.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<title>CSS Fonts IDL tests</title>
+<link rel="help" href="https://drafts.csswg.org/css-fonts-4/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/WebIDLParser.js"></script>
+<script src="/resources/idlharness.js"></script>
+
+<style>
+  div { display: block; }
+</style>
+<style>
+  @font-face {
+    font-family: fwf;
+    src: url(support/fonts/FontWithFancyFeatures.otf);
+  }
+</style>
+
+<script>
+  "use strict";
+
+  idl_test(
+    ["css-fonts"],
+    ["cssom"],
+    idl_array => {
+      idl_array.add_objects({
+        CSSRule: ['cssRule'],
+        CSSFontFaceRule: ['cssFontFaceRule'],
+      });
+      self.cssRule = document.styleSheets[0].cssRules[0];
+      self.cssFontFaceRule = document.styleSheets[1].cssRules[0];
+    }
+  );
+</script>
diff --git a/benchmarks/data/wpt/random/li-type-unsupported-ref.html b/benchmarks/data/wpt/random/li-type-unsupported-ref.html
new file mode 100644
index 00000000..4fbc5aca
--- /dev/null
+++ b/benchmarks/data/wpt/random/li-type-unsupported-ref.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>li@type: unsupported types</title>
+<li>first item</li>
+<li>second item</li>
+<ol>
+  <li>first ordered item</li>
+  <li>second ordered item</li>
+</ol>
+<ul>
+  <li>first unordered item</li>
+  <li>second unordered item</li>
+</ul>
diff --git a/benchmarks/data/wpt/random/moz-css21-float-page-break-inside-avoid-6.html b/benchmarks/data/wpt/random/moz-css21-float-page-break-inside-avoid-6.html
new file mode 100644
index 00000000..3cd0a5fb
--- /dev/null
+++ b/benchmarks/data/wpt/random/moz-css21-float-page-break-inside-avoid-6.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="en-US" class="reftest-paged">
+<head>
+  <title>CSS Test: CSS 2.1 page-break-inside:avoid</title>
+  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=685012">
+  <link rel="help" href="http://www.w3.org/TR/CSS21/page.html#propdef-page-break-inside">
+  <link rel="match" href="moz-css21-float-page-break-inside-avoid-6-ref.html">
+  <meta name="flags" content="paged">
+<style type="text/css">
+@page { size:5in 3in; margin:0.5in; }
+html,body {
+    color:black; background-color:white; font-size:16px; padding:0; margin:0; height:100%;
+}
+p { height:60%; width:90%; margin:0; background-color:blue; border:1px solid black; }
+.test { page-break-inside:avoid; float:left; }
+</style>
+</head>
+<body><p>1</p><p class="test">2</p></body>
+</html>
diff --git a/benchmarks/data/wpt/random/shape-outside-content-box-002.html b/benchmarks/data/wpt/random/shape-outside-content-box-002.html
new file mode 100644
index 00000000..e2040763
--- /dev/null
+++ b/benchmarks/data/wpt/random/shape-outside-content-box-002.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <title>CSS Shape Test: float right, content-box</title>
+  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+  <link rel="help" href="https://drafts.csswg.org/css-shapes-1/#shapes-from-box-values">
+  <link rel="match" href="shape-outside-content-box-002-ref.html">
+  <meta name="flags" content="">
+  <meta name="assert" content="Test the boxes are wrapping around the right float shape defined by the content-box value.">
+  <style>
+  .container {
+    direction: rtl;
+    width: 175px;
+    line-height: 0;
+  }
+
+  .shape {
+    float: right;
+    shape-outside: content-box;
+    box-sizing: content-box;
+    height: 25px;
+    width: 25px;
+    padding: 25px;
+    border: 25px solid lightgreen;
+    margin: 25px;
+    background-color: orange;
+  }
+
+  .box {
+    display: inline-block;
+    width: 50px;
+    height: 25px;
+    background-color: blue;
+  }
+
+  .longbox {
+    display: inline-block;
+    width: 175px;
+    height: 25px;
+    background-color: blue;
+  }
+  </style>
+
+  <main class="container">
+    <div class="shape"></div>
+    <div class="shape"></div>
+    <div class="longbox"></div> <!-- Saturate the margin space -->
+    <div class="longbox"></div> <!-- Saturate the border space -->
+    <div class="longbox"></div> <!-- Saturate the padding space -->
+    <div class="box"></div>
+    <div class="longbox"></div> <!-- Saturate the padding space -->
+    <div class="longbox"></div> <!-- Saturate the border space -->
+    <div class="longbox"></div> <!-- Saturate the margin space -->
+
+    <div class="longbox"></div> <!-- Saturate the margin space -->
+    <div class="longbox"></div> <!-- Saturate the border space -->
+    <div class="longbox"></div> <!-- Saturate the padding space -->
+    <div class="box"></div>
+    <div class="longbox"></div> <!-- Saturate the padding space -->
+    <div class="longbox"></div> <!-- Saturate the border space -->
+    <div class="longbox"></div> <!-- Saturate the margin space -->
+  </main>
+</html>
diff --git a/benchmarks/data/wpt/random/worker-constructor.https.html b/benchmarks/data/wpt/random/worker-constructor.https.html
new file mode 100644
index 00000000..6e127b11
--- /dev/null
+++ b/benchmarks/data/wpt/random/worker-constructor.https.html
@@ -0,0 +1,86 @@
+<!doctype html>
+<html>
+<head>
+  <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<script>
+
+const test_url = "support/WorkerGlobalScope-importScripts.https.js"
+const trusted_url = trustedTypes.createPolicy("anythinggoes", {
+  createScriptURL: x => x}).createScriptURL(test_url);
+const default_url = "support/WorkerGlobalScope-importScripts.potato.js"
+
+async function service_worker(url) {
+  if (!('serviceWorker' in navigator)) return Promise.resolve();
+
+  const scope = 'support/some/scope/for/this/test';
+  const reg = await navigator.serviceWorker.getRegistration(scope);
+  if (reg) await reg.unregister();
+  return await navigator.serviceWorker.register(url, {scope});
+}
+
+// Most tests below don't need promises, but the ones related to
+// ServiceWorkers do. Since we can't mix promise and non-promise tests,
+// we'll just run the non-promise tests in the main function and return
+// an empty-resolved promise for those.
+// Since an active default policy will affect all subsequent DOM operations,
+// we're wrapping policy creation in a promise_test. Together, this will
+// force proper serialization of all tests.
+//
+// Generally, we don't actually care what the workers here do, we'll merely
+// check whether creation succeeds.
+
+promise_test(t => {
+  new Worker(trusted_url);
+  return Promise.resolve();
+}, "Create Worker via ScriptTestUrl");
+
+promise_test(t => {
+  new SharedWorker(trusted_url);
+  return Promise.resolve();
+}, "Create SharedWorker via ScriptTestUrl");
+
+promise_test(t => {
+  return service_worker(trusted_url);
+}, "Create ServiceWorker via ScriptTestUrl");
+
+promise_test(t => {
+  assert_throws_js(TypeError, () => new Worker(test_url));
+  return Promise.resolve();
+}, "Block Worker creation via string");
+
+promise_test(t => {
+  assert_throws_js(TypeError, () => new SharedWorker(test_url));
+  return Promise.resolve();
+}, "Block SharedWorker creation via string");
+
+promise_test(t => {
+  return promise_rejects_js(t, TypeError, service_worker(test_url));
+}, "Block ServiceWorker creation via String");
+
+// Tests with default policy.
+promise_test(t => {
+  trustedTypes.createPolicy("default", {
+      createScriptURL: s => s.replace("potato", "https") });
+  return Promise.resolve();
+}, "Setup default policy.");
+
+promise_test(t => {
+  new Worker(default_url);
+  return Promise.resolve();
+}, "Create Worker via string with default policy.");
+
+promise_test(t => {
+  new SharedWorker(default_url);
+  return Promise.resolve();
+}, "Create SharedWorker via string with default policy.");
+
+promise_test(t => {
+  return service_worker(default_url);
+}, "Create ServiceWorker via string with default policy.");
+
+</script>
+</body>
diff --git a/benchmarks/data/wpt/weighted/2d.composite.image.destination-over.html b/benchmarks/data/wpt/weighted/2d.composite.image.destination-over.html
new file mode 100644
index 00000000..d742f84d
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/2d.composite.image.destination-over.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
+<title>Canvas test: 2d.composite.image.destination-over</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/canvas/resources/canvas-tests.js"></script>
+<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
+<body class="show_output">
+
+<h1>2d.composite.image.destination-over</h1>
+<p class="desc"></p>
+
+
+<p class="output">Actual output:</p>
+<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+<p class="output expectedtext">Expected output:<p><img src="2d.composite.image.destination-over.png" class="output expected" id="expected" alt="">
+<ul id="d"></ul>
+<script>
+var t = async_test("");
+_addTest(function(canvas, ctx) {
+
+
+ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
+ctx.fillRect(0, 0, 100, 50);
+ctx.globalCompositeOperation = 'destination-over';
+ctx.drawImage(document.getElementById('yellow75.png'), 0, 0);
+_assertPixelApprox(canvas, 50,25, 109,255,146,223, "50,25", "109,255,146,223", 5);
+
+
+});
+</script>
+<img src="/images/yellow75.png" id="yellow75.png" class="resource">
+
diff --git a/benchmarks/data/wpt/weighted/align-content-wrap-002.html b/benchmarks/data/wpt/weighted/align-content-wrap-002.html
new file mode 100644
index 00000000..a15f7ea8
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/align-content-wrap-002.html
@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-flexbox/#propdef-align-content" />
+<title>css-flexbox: Tests align-content with flex-wrap: wrap</title>
+<style>
+.flex-horizontal {
+    width:600px;
+    display:flex;
+    height:100px;
+    background:gray;
+    margin-bottom:100px;
+}
+.flex-vertical {
+    width:100px;
+    display:flex;
+    flex-direction: column;
+    height:600px;
+    background:gray;
+    margin-top:200px;
+    margin-bottom:100px;
+}
+.item-horizontal {
+    width:150px;
+    background:yellow;
+    margin:10px;
+    flex:none;
+}
+.item-vertical {
+    height:150px;
+    background:yellow;
+    margin:10px;
+    flex:none;
+}
+.content1-horizontal {
+    width:100px;
+    height:150px;
+    background:red;
+}
+.content2-horizontal {
+    width:100px;
+    height:100px;
+    background:red;
+}
+.content3-horizontal {
+    width:100px;
+    height:50px;
+    background:red;
+}
+.content1-vertical {
+    width:150px;
+    height:100px;
+    background:red;
+}
+.content2-vertical {
+    width:100px;
+    height:100px;
+    background:red;
+}
+.content3-vertical {
+    width:50px;
+    height:100px;
+    background:red;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+<body onload="checkLayout('.flex-horizontal, .flex-vertical');">
+<div id=log></div>
+<p>Test for crbug.com/362848: Flex box word-wrap is not adhering to spec</p>
+<div class="flex-horizontal">
+    <div class="item-horizontal" data-expected-height="80"><div class="content1-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="80"><div class="content2-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="80"><div class="content3-horizontal"></div></div>
+</div>
+
+<div class="flex-horizontal" style="flex-wrap:wrap;">
+    <div class="item-horizontal" data-expected-height="150"><div class="content1-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="150"><div class="content2-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="150"><div class="content3-horizontal"></div></div>
+</div>
+
+<div class="flex-horizontal" style="flex-wrap:wrap;">
+    <div class="item-horizontal" data-expected-height="150"><div class="content1-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="150"><div class="content2-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="150"><div class="content3-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="150"><div class="content1-horizontal"></div></div>
+    <div class="item-horizontal" data-expected-height="150"><div class="content2-horizontal"></div></div>
+</div>
+
+<div class="flex-vertical">
+    <div class="item-vertical" data-expected-width="80"><div class="content1-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="80"><div class="content2-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="80"><div class="content3-vertical"></div></div>
+</div>
+
+<div class="flex-vertical" style="flex-wrap:wrap;">
+    <div class="item-vertical" data-expected-width="150"><div class="content1-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="150"><div class="content2-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="150"><div class="content3-vertical"></div></div>
+</div>
+
+<div class="flex-vertical" style="flex-wrap:wrap;">
+    <div class="item-vertical" data-expected-width="150"><div class="content1-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="150"><div class="content2-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="150"><div class="content3-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="150"><div class="content1-vertical"></div></div>
+    <div class="item-vertical" data-expected-width="150"><div class="content2-vertical"></div></div>
+</div>
diff --git a/benchmarks/data/wpt/weighted/big5_chars_extra.html b/benchmarks/data/wpt/weighted/big5_chars_extra.html
new file mode 100644
index 00000000..5ea8e574
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/big5_chars_extra.html
@@ -0,0 +1 @@
+<!doctype html><html><head><meta charset="big5"><title>big5 characters</title></head><body><span data-cp="C0" data-bytes="88 59">ˆY</span> <span data-cp="C1" data-bytes="88 57">ˆW</span> <span data-cp="C8" data-bytes="88 5D">ˆ]</span> <span data-cp="C9" data-bytes="88 5B">ˆ[</span> <span data-cp="CA" data-bytes="88 66">ˆf</span> <span data-cp="D2" data-bytes="88 61">ˆa</span> <span data-cp="D3" data-bytes="88 5F">ˆ_</span> <span data-cp="E0" data-bytes="88 6A">ˆj</span> <span data-cp="E1" data-bytes="88 68">ˆh</span> <span data-cp="E8" data-bytes="88 6F">ˆo</span> <span data-cp="E9" data-bytes="88 6D">ˆm</span> <span data-cp="EA" data-bytes="88 A7">ˆ§</span> <span data-cp="EC" data-bytes="88 73">ˆs</span> <span data-cp="ED" data-bytes="88 71">ˆq</span> <span data-cp="F2" data-bytes="88 77">ˆw</span> <span data-cp="F3" data-bytes="88 75">ˆu</span> <span data-cp="F9" data-bytes="88 7B">ˆ{</span> <span data-cp="FA" data-bytes="88 79">ˆy</span> <span data-cp="FC" data-bytes="88 A2">ˆ¢</span> <span data-cp="100" data-bytes="88 56">ˆV</span> <span data-cp="101" data-bytes="88 67">ˆg</span> <span data-cp="112" data-bytes="88 5A">ˆZ</span> <span data-cp="113" data-bytes="88 6C">ˆl</span> <span data-cp="11A" data-bytes="88 5C">ˆ\</span> <span data-cp="11B" data-bytes="88 6E">ˆn</span> <span data-cp="12B" data-bytes="88 70">ˆp</span> <span data-cp="14C" data-bytes="88 5E">ˆ^</span> <span data-cp="14D" data-bytes="88 74">ˆt</span> <span data-cp="16B" data-bytes="88 78">ˆx</span> <span data-cp="1CD" data-bytes="88 58">ˆX</span> <span data-cp="1CE" data-bytes="88 69">ˆi</span> <span data-cp="1D0" data-bytes="88 72">ˆr</span> <span data-cp="1D1" data-bytes="88 60">ˆ`</span> <span data-cp="1D2" data-bytes="88 76">ˆv</span> <span data-cp="1D4" data-bytes="88 7A">ˆz</span> <span data-cp="1D6" data-bytes="88 7C">ˆ|</span> <span data-cp="1D8" data-bytes="88 7D">ˆ}</span> <span data-cp="1DA" data-bytes="88 7E">ˆ~</span> <span data-cp="1DC" data-bytes="88 A1">ˆ¡</span> <span data-cp="251" data-bytes="88 6B">ˆk</span> <span data-cp="261" data-bytes="88 A8">ˆ¨</span> <span data-cp="1EBE" data-bytes="88 63">ˆc</span> <span data-cp="1EBF" data-bytes="88 A4">ˆ¤</span> <span data-cp="1EC0" data-bytes="88 65">ˆe</span> <span data-cp="1EC1" data-bytes="88 A6">ˆ¦</span> <span data-cp="23DA" data-bytes="88 A9">ˆ©</span> <span data-cp="23DB" data-bytes="88 AA">ˆª</span> <span data-cp="31C0" data-bytes="88 40">ˆ@</span> <span data-cp="31C1" data-bytes="88 41">ˆA</span> <span data-cp="31C2" data-bytes="88 42">ˆB</span> <span data-cp="31C3" data-bytes="88 43">ˆC</span> <span data-cp="31C4" data-bytes="88 44">ˆD</span> <span data-cp="31C5" data-bytes="88 46">ˆF</span> <span data-cp="31C6" data-bytes="88 49">ˆI</span> <span data-cp="31C7" data-bytes="88 4A">ˆJ</span> <span data-cp="31C8" data-bytes="88 4D">ˆM</span> <span data-cp="31C9" data-bytes="88 4F">ˆO</span> <span data-cp="31CA" data-bytes="88 50">ˆP</span> <span data-cp="31CB" data-bytes="88 51">ˆQ</span> <span data-cp="31CC" data-bytes="88 52">ˆR</span> <span data-cp="31CD" data-bytes="88 54">ˆT</span> <span data-cp="31CE" data-bytes="88 55">ˆU</span> <span data-cp="3435" data-bytes="92 77">’w</span> <span data-cp="3440" data-bytes="96 DF">–ß</span> <span data-cp="344A" data-bytes="8C F4">Œô</span> <span data-cp="344C" data-bytes="89 D5">‰Õ</span> <span data-cp="3464" data-bytes="93 CD">“Í</span> <span data-cp="3473" data-bytes="9B DF">›ß</span> <span data-cp="347D" data-bytes="89 DA">‰Ú</span> <span data-cp="347E" data-bytes="8F 59">�Y</span> <span data-cp="3493" data-bytes="89 DB">‰Û</span> <span data-cp="3496" data-bytes="8F 5D">�]</span> <span data-cp="34A5" data-bytes="89 DC">‰Ü</span> <span data-cp="34AF" data-bytes="96 F7">–÷</span> <span data-cp="34BC" data-bytes="8A DA">ŠÚ</span> <span data-cp="34C1" data-bytes="8B DC">‹Ü</span> <span data-cp="34C8" data-bytes="97 DB">—Û</span> <span data-cp="34DF" data-bytes="9E 53">žS</span> <span data-cp="34E4" data-bytes="9D AA">�ª</span> <span data-cp="34E6" data-bytes="87 BE">‡¾</span> <span data-cp="34FB" data-bytes="9B EA">›ê</span> <span data-cp="3506" data-bytes="8A 6E">Šn</span> <span data-cp="353E" data-bytes="8B C8">‹È</span> <span data-cp="3551" data-bytes="89 E8">‰è</span> <span data-cp="3553" data-bytes="89 EA">‰ê</span> <span data-cp="3559" data-bytes="8C 4B">ŒK</span> <span data-cp="356D" data-bytes="89 ED">‰í</span> <span data-cp="3570" data-bytes="94 DD">”Ý</span> <span data-cp="3572" data-bytes="89 EE">‰î</span> <span data-cp="3577" data-bytes="9E B4">ž´</span> <span data-cp="3578" data-bytes="8A D3">ŠÓ</span> <span data-cp="3584" data-bytes="92 DB">’Û</span> <span data-cp="3597" data-bytes="94 DB">”Û</span> <span data-cp="3598" data-bytes="89 F9">‰ù</span> <span data-cp="35A5" data-bytes="89 FB">‰û</span> <span data-cp="35AD" data-bytes="9E FC">žü</span> <span data-cp="35BF" data-bytes="89 FC">‰ü</span> <span data-cp="35C1" data-bytes="89 BF">‰¿</span> <span data-cp="35C5" data-bytes="89 FE">‰þ</span> <span data-cp="35C7" data-bytes="89 E6">‰æ</span> <span data-cp="35CA" data-bytes="9D 46">�F</span> <span data-cp="35CE" data-bytes="9D EE">�î</span> <span data-cp="35D2" data-bytes="A0 7E"> ~</span> <span data-cp="35D6" data-bytes="A0 68"> h</span> <span data-cp="35DB" data-bytes="98 E9">˜é</span> <span data-cp="35DD" data-bytes="8B 68">‹h</span> <span data-cp="35F1" data-bytes="8D FD">�ý</span> <span data-cp="35F2" data-bytes="8B BE">‹¾</span> <span data-cp="35F3" data-bytes="9F D9">ŸÙ</span> <span data-cp="35FB" data-bytes="8A EB">Šë</span> <span data-cp="35FE" data-bytes="9F D7">Ÿ×</span> <span data-cp="3609" data-bytes="8B 6A">‹j</span> <span data-cp="3618" data-bytes="9C 5C">œ\</span> <span data-cp="361A" data-bytes="8B B1">‹±</span> <span data-cp="3625" data-bytes="87 70">‡p</span> <span data-cp="362D" data-bytes="9D F3">�ó</span> <span data-cp="3635" data-bytes="A0 D0"> Ð</span> <span data-cp="363E" data-bytes="92 E9">’é</span> <span data-cp="3647" data-bytes="9A EC">šì</span> <span data-cp="3648" data-bytes="8F AB">�«</span> <span data-cp="364E" data-bytes="8E 45">ŽE</span> <span data-cp="365F" data-bytes="9C 6F">œo</span> <span data-cp="3661" data-bytes="8D 5C">�\</span> <span data-cp="367A" data-bytes="9E DE">žÞ</span> <span data-cp="3681" data-bytes="89 EF">‰ï</span> <span data-cp="369A" data-bytes="96 E9">–é</span> <span data-cp="36A5" data-bytes="9E BB">ž»</span> <span data-cp="36AA" data-bytes="94 DE">”Þ</span> <span data-cp="36AC" data-bytes="9E B8">ž¸</span> <span data-cp="36B0" data-bytes="97 BA">—º</span> <span data-cp="36B5" data-bytes="95 D6">•Ö</span> <span data-cp="36B9" data-bytes="9C BB">œ»</span> <span data-cp="36BC" data-bytes="97 DA">—Ú</span> <span data-cp="36C1" data-bytes="8F 45">�E</span> <span data-cp="36C4" data-bytes="91 58">‘X</span> <span data-cp="36C7" data-bytes="98 56">˜V</span> <span data-cp="36C8" data-bytes="9B 4D">›M</span> <span data-cp="36D3" data-bytes="93 5B">“[</span> <span data-cp="36D4" data-bytes="95 C7">•Ç</span> <span data-cp="36D6" data-bytes="97 E7">—ç</span> <span data-cp="36DD" data-bytes="93 59">“Y</span> <span data-cp="36E1" data-bytes="91 F5">‘õ</span> <span data-cp="36E2" data-bytes="97 B8">—¸</span> <span data-cp="36F5" data-bytes="92 FA">’ú</span> <span data-cp="3701" data-bytes="93 57">“W</span> <span data-cp="3703" data-bytes="8B A6">‹¦</span> <span data-cp="370A" data-bytes="97 B0">—°</span> <span data-cp="371C" data-bytes="9C A1">œ¡</span> <span data-cp="3722" data-bytes="91 F2">‘ò</span> <span data-cp="3723" data-bytes="91 F9">‘ù</span> <span data-cp="3725" data-bytes="8F F1">�ñ</span> <span data-cp="372C" data-bytes="97 45">—E</span> <span data-cp="372D" data-bytes="98 53">˜S</span> <span data-cp="3733" data-bytes="92 51">’Q</span> <span data-cp="373A" data-bytes="9D AD">�­</span> <span data-cp="3762" data-bytes="9B C2">›Â</span> <span data-cp="376F" data-bytes="9A 7B">š{</span> <span data-cp="3797" data-bytes="8B 60">‹`</span> <span data-cp="37A0" data-bytes="93 4B">“K</span> <span data-cp="37B9" data-bytes="9A BD">š½</span> <span data-cp="37BE" data-bytes="91 B7">‘·</span> <span data-cp="37D6" data-bytes="8D 4B">�K</span> <span data-cp="37F2" data-bytes="95 B4">•´</span> <span data-cp="37FB" data-bytes="9E F0">žð</span> <span data-cp="380F" data-bytes="8D 64">�d</span> <span data-cp="3819" data-bytes="92 69">’i</span> <span data-cp="3820" data-bytes="8D 67">�g</span> <span data-cp="3838" data-bytes="8D 68">�h</span> <span data-cp="3863" data-bytes="93 EB">“ë</span> <span data-cp="3875" data-bytes="87 7A">‡z</span> <span data-cp="38C3" data-bytes="91 66">‘f</span> <span data-cp="38D1" data-bytes="93 DD">“Ý</span> <span data-cp="38D4" data-bytes="8D 52">�R</span> <span data-cp="38FA" data-bytes="8B CC">‹Ì</span> <span data-cp="3908" data-bytes="8D 6D">�m</span> <span data-cp="3914" data-bytes="8D 6E">�n</span> <span data-cp="3927" data-bytes="96 A8">–¨</span> <span data-cp="393F" data-bytes="8D 6F">�o</span> <span data-cp="394D" data-bytes="8D 70">�p</span> <span data-cp="3978" data-bytes="8C F3">Œó</span> <span data-cp="3980" data-bytes="90 60">�`</span> <span data-cp="3989" data-bytes="8D 74">�t</span> <span data-cp="398A" data-bytes="97 C3">—Ã</span> <span data-cp="3992" data-bytes="8A D0">ŠÐ</span> <span data-cp="3999" data-bytes="92 74">’t</span> <span data-cp="399B" data-bytes="9B BE">›¾</span> <span data-cp="39A1" data-bytes="9C C8">œÈ</span> <span data-cp="39A4" data-bytes="9C BA">œº</span> <span data-cp="39B8" data-bytes="8D 78">�x</span> <span data-cp="39DC" data-bytes="9E B9">ž¹</span> <span data-cp="39E2" data-bytes="95 5A">•Z</span> <span data-cp="39E5" data-bytes="91 B4">‘´</span> <span data-cp="39EC" data-bytes="8A 48">ŠH</span> <span data-cp="39F8" data-bytes="8D 7D">�}</span> <span data-cp="39FB" data-bytes="8A 7D">Š}</span> <span data-cp="39FE" data-bytes="8A C2">ŠÂ</span> <span data-cp="3A03" data-bytes="8D A1">�¡</span> <span data-cp="3A06" data-bytes="8A D1">ŠÑ</span> <span data-cp="3A18" data-bytes="8B 47">‹G</span> <span data-cp="3A29" data-bytes="93 A4">“¤</span> <span data-cp="3A2A" data-bytes="9E DA">žÚ</span> <span data-cp="3A34" data-bytes="8A 51">ŠQ</span> <span data-cp="3A4B" data-bytes="8D A6">�¦</span> <span data-cp="3A52" data-bytes="9E C5">žÅ</span> <span data-cp="3A5C" data-bytes="A0 78"> x</span> <span data-cp="3A5E" data-bytes="94 B5">”µ</span> <span data-cp="3A67" data-bytes="8A 6B">Šk</span> <span data-cp="3A97" data-bytes="8D AB">�«</span> <span data-cp="3ABD" data-bytes="8D AD">�­</span> <span data-cp="3AE0" data-bytes="93 C1">“Á</span> <span data-cp="3AF0" data-bytes="90 6F">�o</span> <span data-cp="3AF2" data-bytes="8D B0">�°</span> <span data-cp="3AF5" data-bytes="87 A2">‡¢</span> <span data-cp="3AFB" data-bytes="94 7E">”~</span> <span data-cp="3B0E" data-bytes="90 FA">�ú</span> <span data-cp="3B19" data-bytes="94 79">”y</span> <span data-cp="3B22" data-bytes="8D B2">�²</span> <span data-cp="3B39" data-bytes="99 7B">™{</span> <span data-cp="3B42" data-bytes="8D B4">�´</span> <span data-cp="3B58" data-bytes="8D B7">�·</span> <span data-cp="3B60" data-bytes="91 B3">‘³</span> <span data-cp="3B71" data-bytes="8D BB">�»</span> <span data-cp="3B72" data-bytes="8D BA">�º</span> <span data-cp="3B7B" data-bytes="8D BC">�¼</span> <span data-cp="3B7C" data-bytes="90 44">�D</span> <span data-cp="3B95" data-bytes="87 4B">‡K</span> <span data-cp="3B96" data-bytes="93 E4">“ä</span> <span data-cp="3B99" data-bytes="93 E0">“à</span> <span data-cp="3BBC" data-bytes="8D C3">�Ã</span> <span data-cp="3BBE" data-bytes="9B B8">›¸</span> <span data-cp="3BC4" data-bytes="93 E9">“é</span> <span data-cp="3BD7" data-bytes="93 F6">“ö</span> <span data-cp="3BDD" data-bytes="8D C5">�Å</span> <span data-cp="3BEC" data-bytes="8D CA">�Ê</span> <span data-cp="3BF2" data-bytes="8D CC">�Ì</span> <span data-cp="3BF4" data-bytes="93 B5">“µ</span> <span data-cp="3C11" data-bytes="9C F8">œø</span> <span data-cp="3C15" data-bytes="92 52">’R</span> <span data-cp="3C18" data-bytes="A0 E8"> è</span> <span data-cp="3C54" data-bytes="9C A5">œ¥</span> <span data-cp="3C8B" data-bytes="8C 56">ŒV</span> <span data-cp="3CCB" data-bytes="8D D6">�Ö</span> <span data-cp="3CCD" data-bytes="97 C0">—À</span> <span data-cp="3CD1" data-bytes="A0 DE"> Þ</span> <span data-cp="3CD6" data-bytes="97 D2">—Ò</span> <span data-cp="3CEF" data-bytes="8D DB">�Û</span> <span data-cp="3D12" data-bytes="8C EA">Œê</span> <span data-cp="3D13" data-bytes="8E AF">Ž¯</span> <span data-cp="3D1D" data-bytes="91 B5">‘µ</span> <span data-cp="3D46" data-bytes="8D EB">�ë</span> <span data-cp="3D4C" data-bytes="97 C6">—Æ</span> <span data-cp="3D51" data-bytes="90 FC">�ü</span> <span data-cp="3D62" data-bytes="96 D6">–Ö</span> <span data-cp="3D69" data-bytes="97 C5">—Å</span> <span data-cp="3D6A" data-bytes="8D EF">�ï</span> <span data-cp="3D6F" data-bytes="97 D7">—×</span> <span data-cp="3D75" data-bytes="8D F0">�ð</span> <span data-cp="3D7D" data-bytes="96 A6">–¦</span> <span data-cp="3D88" data-bytes="8C DF">Œß</span> <span data-cp="3D8A" data-bytes="8D F3">�ó</span> <span data-cp="3D8F" data-bytes="94 49">”I</span> <span data-cp="3D91" data-bytes="8D F5">�õ</span> <span data-cp="3DA5" data-bytes="98 72">˜r</span> <span data-cp="3DAD" data-bytes="8E 6B">Žk</span> <span data-cp="3DBF" data-bytes="8F 50">�P</span> <span data-cp="3DC6" data-bytes="9D CC">�Ì</span> <span data-cp="3DC9" data-bytes="8C 44">ŒD</span> <span data-cp="3DCC" data-bytes="99 6E">™n</span> <span data-cp="3DCD" data-bytes="94 A1">”¡</span> <span data-cp="3DD3" data-bytes="8F 63">�c</span> <span data-cp="3DDB" data-bytes="A0 DA"> Ú</span> <span data-cp="3DE7" data-bytes="92 53">’S</span> <span data-cp="3DEB" data-bytes="9D B5">�µ</span> <span data-cp="3DF3" data-bytes="98 79">˜y</span> <span data-cp="3DF4" data-bytes="87 6A">‡j</span> <span data-cp="3DF7" data-bytes="9D 5D">�]</span> <span data-cp="3DFC" data-bytes="8D 63">�c</span> <span data-cp="3DFD" data-bytes="96 69">–i</span> <span data-cp="3E06" data-bytes="9F 70">Ÿp</span> <span data-cp="3E43" data-bytes="8A C7">ŠÇ</span> <span data-cp="3E48" data-bytes="89 D7">‰×</span> <span data-cp="3E74" data-bytes="9E DD">žÝ</span> <span data-cp="3EA9" data-bytes="98 BC">˜¼</span> <span data-cp="3EAD" data-bytes="95 B0">•°</span> <span data-cp="3EB1" data-bytes="94 64">”d</span> <span data-cp="3EB8" data-bytes="93 6F">“o</span> <span data-cp="3EBF" data-bytes="94 B9">”¹</span> <span data-cp="3EC2" data-bytes="95 EC">•ì</span> <span data-cp="3EC7" data-bytes="91 EE">‘î</span> <span data-cp="3ECA" data-bytes="98 C3">˜Ã</span> <span data-cp="3ECC" data-bytes="95 F6">•ö</span> <span data-cp="3ED0" data-bytes="8F FD">�ý</span> <span data-cp="3ED1" data-bytes="98 C5">˜Å</span> <span data-cp="3ED6" data-bytes="97 66">—f</span> <span data-cp="3EDA" data-bytes="97 DD">—Ý</span> <span data-cp="3EDB" data-bytes="8C AA">Œª</span> <span data-cp="3EDE" data-bytes="92 D2">’Ò</span> <span data-cp="3EE1" data-bytes="97 61">—a</span> <span data-cp="3EE2" data-bytes="98 CB">˜Ë</span> <span data-cp="3EE7" data-bytes="95 F0">•ð</span> <span data-cp="3EE9" data-bytes="97 5D">—]</span> <span data-cp="3EEB" data-bytes="91 E3">‘ã</span> <span data-cp="3EEC" data-bytes="87 7E">‡~</span> <span data-cp="3EF0" data-bytes="98 CC">˜Ì</span> <span data-cp="3EF3" data-bytes="94 69">”i</span> <span data-cp="3EF4" data-bytes="98 CD">˜Í</span> <span data-cp="3EFA" data-bytes="98 CE">˜Î</span> <span data-cp="3EFC" data-bytes="95 FC">•ü</span> <span data-cp="3EFF" data-bytes="94 A3">”£</span> <span data-cp="3F00" data-bytes="96 62">–b</span> <span data-cp="3F06" data-bytes="94 63">”c</span> <span data-cp="3F07" data-bytes="8D 47">�G</span> <span data-cp="3F0E" data-bytes="98 D0">˜Ð</span> <span data-cp="3F53" data-bytes="98 D1">˜Ñ</span> <span data-cp="3F58" data-bytes="94 75">”u</span> <span data-cp="3F63" data-bytes="94 72">”r</span> <span data-cp="3F7C" data-bytes="98 D6">˜Ö</span> <span data-cp="3F93" data-bytes="8A F0">Šð</span> <span data-cp="3FC0" data-bytes="98 D9">˜Ù</span> <span data-cp="3FC8" data-bytes="8D 5A">�Z</span> <span data-cp="3FD7" data-bytes="98 DB">˜Û</span> <span data-cp="3FDC" data-bytes="98 DD">˜Ý</span> <span data-cp="3FE5" data-bytes="98 A8">˜¨</span> <span data-cp="3FED" data-bytes="8A 6D">Šm</span> <span data-cp="3FF9" data-bytes="8A FB">Šû</span> <span data-cp="3FFA" data-bytes="8A AE">Š®</span> <span data-cp="4009" data-bytes="8C 5D">Œ]</span> <span data-cp="401D" data-bytes="98 E4">˜ä</span> <span data-cp="4039" data-bytes="98 E6">˜æ</span> <span data-cp="4045" data-bytes="98 E8">˜è</span> <span data-cp="4053" data-bytes="8A 4D">ŠM</span> <span data-cp="4057" data-bytes="92 57">’W</span> <span data-cp="4062" data-bytes="95 DF">•ß</span> <span data-cp="4065" data-bytes="A0 AC"> ¬</span> <span data-cp="406A" data-bytes="98 EB">˜ë</span> <span data-cp="406F" data-bytes="98 EC">˜ì</span> <span data-cp="4071" data-bytes="8C C3">ŒÃ</span> <span data-cp="40A8" data-bytes="98 F4">˜ô</span> <span data-cp="40B4" data-bytes="87 D9">‡Ù</span> <span data-cp="40BB" data-bytes="8A B8">Š¸</span> <span data-cp="40BF" data-bytes="9E E7">žç</span> <span data-cp="40C8" data-bytes="94 BC">”¼</span> <span data-cp="40DF" data-bytes="9C C6">œÆ</span> <span data-cp="40F8" data-bytes="8D 4A">�J</span> <span data-cp="40FA" data-bytes="9E 7E">ž~</span> <span data-cp="4102" data-bytes="8D 44">�D</span> <span data-cp="4103" data-bytes="98 FE">˜þ</span> <span data-cp="4109" data-bytes="99 40">™@</span> <span data-cp="410E" data-bytes="94 C9">”É</span> <span data-cp="4131" data-bytes="87 C6">‡Æ</span> <span data-cp="4132" data-bytes="94 D3">”Ó</span> <span data-cp="4167" data-bytes="99 46">™F</span> <span data-cp="416C" data-bytes="90 C0">�À</span> <span data-cp="416E" data-bytes="94 D1">”Ñ</span> <span data-cp="417C" data-bytes="8D 4E">�N</span> <span data-cp="417F" data-bytes="95 73">•s</span> <span data-cp="4181" data-bytes="87 CE">‡Î</span> <span data-cp="4190" data-bytes="93 C2">“Â</span> <span data-cp="41B2" data-bytes="99 48">™H</span> <span data-cp="41C4" data-bytes="99 4B">™K</span> <span data-cp="41CA" data-bytes="8E 55">ŽU</span> <span data-cp="41CF" data-bytes="99 4E">™N</span> <span data-cp="41DB" data-bytes="8E FE">Žþ</span> <span data-cp="41ED" data-bytes="8D 5F">�_</span> <span data-cp="41EF" data-bytes="8E 59">ŽY</span> <span data-cp="41F9" data-bytes="94 EC">”ì</span> <span data-cp="4211" data-bytes="94 EF">”ï</span> <span data-cp="4223" data-bytes="8C 60">Œ`</span> <span data-cp="4240" data-bytes="8F 74">�t</span> <span data-cp="4260" data-bytes="99 55">™U</span> <span data-cp="426A" data-bytes="95 44">•D</span> <span data-cp="4276" data-bytes="8C CB">ŒË</span> <span data-cp="427A" data-bytes="99 56">™V</span> <span data-cp="428C" data-bytes="99 59">™Y</span> <span data-cp="4294" data-bytes="99 5B">™[</span> <span data-cp="42A2" data-bytes="8C C4">ŒÄ</span> <span data-cp="42B9" data-bytes="90 B7">�·</span> <span data-cp="42BC" data-bytes="97 43">—C</span> <span data-cp="42F4" data-bytes="95 CD">•Í</span> <span data-cp="42FB" data-bytes="97 C9">—É</span> <span data-cp="430A" data-bytes="87 AA">‡ª</span> <span data-cp="432B" data-bytes="8E B9">Ž¹</span> <span data-cp="436E" data-bytes="95 C6">•Æ</span> <span data-cp="4397" data-bytes="99 67">™g</span> <span data-cp="439A" data-bytes="8C E3">Œã</span> <span data-cp="43BA" data-bytes="8A B9">Š¹</span> <span data-cp="43C1" data-bytes="8D FC">�ü</span> <span data-cp="43D9" data-bytes="8A 76">Šv</span> <span data-cp="43DF" data-bytes="9D 51">�Q</span> <span data-cp="43ED" data-bytes="99 73">™s</span> <span data-cp="43F0" data-bytes="87 40">‡@</span> <span data-cp="43F2" data-bytes="9D 4F">�O</span> <span data-cp="4401" data-bytes="99 7A">™z</span> <span data-cp="4402" data-bytes="95 64">•d</span> <span data-cp="4413" data-bytes="99 A1">™¡</span> <span data-cp="4425" data-bytes="99 A5">™¥</span> <span data-cp="442D" data-bytes="99 A7">™§</span> <span data-cp="447A" data-bytes="8E ED">Ží</span> <span data-cp="448F" data-bytes="99 AD">™­</span> <span data-cp="449F" data-bytes="94 6E">”n</span> <span data-cp="44A0" data-bytes="8F 70">�p</span> <span data-cp="44B0" data-bytes="99 B3">™³</span> <span data-cp="44B7" data-bytes="A0 53"> S</span> <span data-cp="44BD" data-bytes="8D 5E">�^</span> <span data-cp="44C0" data-bytes="96 5C">–\</span> <span data-cp="44C3" data-bytes="8C E0">Œà</span> <span data-cp="44CE" data-bytes="97 FE">—þ</span> <span data-cp="44DD" data-bytes="92 BD">’½</span> <span data-cp="44DE" data-bytes="8D 5D">�]</span> <span data-cp="44DF" data-bytes="97 FD">—ý</span> <span data-cp="44E1" data-bytes="87 DB">‡Û</span> <span data-cp="44E4" data-bytes="8F 64">�d</span> <span data-cp="44EA" data-bytes="95 62">•b</span> <span data-cp="44EB" data-bytes="97 CD">—Í</span> <span data-cp="44EC" data-bytes="9E 64">žd</span> <span data-cp="44F4" data-bytes="92 4C">’L</span> <span data-cp="4503" data-bytes="8E C9">ŽÉ</span> <span data-cp="4504" data-bytes="99 BC">™¼</span> <span data-cp="4509" data-bytes="9D A5">�¥</span> <span data-cp="450B" data-bytes="8F 54">�T</span> <span data-cp="4516" data-bytes="8F 7C">�|</span> <span data-cp="451B" data-bytes="8D 55">�U</span> <span data-cp="451D" data-bytes="8E A2">Ž¢</span> <span data-cp="4527" data-bytes="8F 7A">�z</span> <span data-cp="452E" data-bytes="97 AE">—®</span> <span data-cp="4533" data-bytes="96 C8">–È</span> <span data-cp="4536" data-bytes="8C E4">Œä</span> <span data-cp="453B" data-bytes="99 C3">™Ã</span> <span data-cp="453D" data-bytes="90 D6">�Ö</span> <span data-cp="453F" data-bytes="9C BE">œ¾</span> <span data-cp="4543" data-bytes="8F 76">�v</span> <span data-cp="4551" data-bytes="94 70">”p</span> <span data-cp="4558" data-bytes="8C EF">Œï</span> <span data-cp="455C" data-bytes="8E C7">ŽÇ</span> <span data-cp="4561" data-bytes="8D 54">�T</span> <span data-cp="4562" data-bytes="A0 F9"> ù</span> <span data-cp="456A" data-bytes="8F A9">�©</span> <span data-cp="456D" data-bytes="8D 51">�Q</span> <span data-cp="4577" data-bytes="99 C7">™Ç</span> <span data-cp="4578" data-bytes="87 44">‡D</span> <span data-cp="4585" data-bytes="90 D7">�×</span> <span data-cp="45A6" data-bytes="87 43">‡C</span> <span data-cp="45B3" data-bytes="87 47">‡G</span> <span data-cp="45DA" data-bytes="87 58">‡X</span> <span data-cp="45E9" data-bytes="9E DF">žß</span> <span data-cp="45EA" data-bytes="8D 59">�Y</span> <span data-cp="4603" data-bytes="87 42">‡B</span> <span data-cp="4606" data-bytes="99 CE">™Î</span> <span data-cp="460F" data-bytes="8F BA">�º</span> <span data-cp="4615" data-bytes="8F EB">�ë</span> <span data-cp="4617" data-bytes="99 CF">™Ï</span> <span data-cp="465B" data-bytes="8F C2">�Â</span> <span data-cp="467A" data-bytes="92 C9">’É</span> <span data-cp="4680" data-bytes="97 DC">—Ü</span> <span data-cp="46A1" data-bytes="87 5D">‡]</span> <span data-cp="46AE" data-bytes="87 CC">‡Ì</span> <span data-cp="46BB" data-bytes="8D 45">�E</span> <span data-cp="46CF" data-bytes="95 B3">•³</span> <span data-cp="46D0" data-bytes="9C 79">œy</span> <span data-cp="46F5" data-bytes="95 B2">•²</span> <span data-cp="46F7" data-bytes="8D 4C">�L</span> <span data-cp="4713" data-bytes="8F DB">�Û</span> <span data-cp="4718" data-bytes="9B E3">›ã</span> <span data-cp="4736" data-bytes="87 4C">‡L</span> <span data-cp="4744" data-bytes="87 4D">‡M</span> <span data-cp="474E" data-bytes="9E 7A">žz</span> <span data-cp="474F" data-bytes="87 57">‡W</span> <span data-cp="477C" data-bytes="9B EE">›î</span> <span data-cp="4798" data-bytes="99 DE">™Þ</span> <span data-cp="47D5" data-bytes="8A 52">ŠR</span> <span data-cp="47ED" data-bytes="99 E1">™á</span> <span data-cp="47F4" data-bytes="8A 67">Šg</span> <span data-cp="4800" data-bytes="8B B5">‹µ</span> <span data-cp="480B" data-bytes="8A AC">Š¬</span> <span data-cp="4837" data-bytes="99 E9">™é</span> <span data-cp="4871" data-bytes="97 DE">—Þ</span> <span data-cp="489B" data-bytes="95 D1">•Ñ</span> <span data-cp="48AD" data-bytes="99 F5">™õ</span> <span data-cp="48D0" data-bytes="9B A9">›©</span> <span data-cp="48F3" data-bytes="9E A4">ž¤</span> <span data-cp="48FA" data-bytes="9D 49">�I</span> <span data-cp="4906" data-bytes="95 DB">•Û</span> <span data-cp="4911" data-bytes="89 C5">‰Å</span> <span data-cp="491E" data-bytes="99 F8">™ø</span> <span data-cp="4925" data-bytes="96 64">–d</span> <span data-cp="492A" data-bytes="90 55">�U</span> <span data-cp="492D" data-bytes="96 D4">–Ô</span> <span data-cp="492F" data-bytes="87 C4">‡Ä</span> <span data-cp="4930" data-bytes="87 AE">‡®</span> <span data-cp="4935" data-bytes="97 7C">—|</span> <span data-cp="493C" data-bytes="96 4D">–M</span> <span data-cp="493E" data-bytes="97 E1">—á</span> <span data-cp="4945" data-bytes="9A 48">šH</span> <span data-cp="4951" data-bytes="9A 49">šI</span> <span data-cp="4965" data-bytes="90 AA">�ª</span> <span data-cp="496A" data-bytes="9A 50">šP</span> <span data-cp="4972" data-bytes="93 47">“G</span> <span data-cp="4989" data-bytes="8E D8">ŽØ</span> <span data-cp="49A1" data-bytes="90 C9">�É</span> <span data-cp="49A7" data-bytes="9A 55">šU</span> <span data-cp="49DF" data-bytes="90 BC">�¼</span> <span data-cp="49E5" data-bytes="9A 58">šX</span> <span data-cp="49E7" data-bytes="8B B8">‹¸</span> <span data-cp="4A0F" data-bytes="90 D5">�Õ</span> <span data-cp="4A1D" data-bytes="96 41">–A</span> <span data-cp="4A24" data-bytes="9A 5A">šZ</span> <span data-cp="4A35" data-bytes="9A 5C">š\</span> <span data-cp="4A96" data-bytes="97 C2">—Â</span> <span data-cp="4AA4" data-bytes="87 5C">‡\</span> <span data-cp="4AB4" data-bytes="8A BB">Š»</span> <span data-cp="4AB8" data-bytes="9B AA">›ª</span> <span data-cp="4AD1" data-bytes="90 F5">�õ</span> <span data-cp="4AE4" data-bytes="9A 60">š`</span> <span data-cp="4AFF" data-bytes="91 45">‘E</span> <span data-cp="4B10" data-bytes="8C 58">ŒX</span> <span data-cp="4B19" data-bytes="9A 63">šc</span> <span data-cp="4B20" data-bytes="8C 49">ŒI</span> <span data-cp="4B2C" data-bytes="8B B6">‹¶</span> <span data-cp="4B6F" data-bytes="96 6B">–k</span> <span data-cp="4B70" data-bytes="9A 6E">šn</span> <span data-cp="4B72" data-bytes="91 4F">‘O</span> <span data-cp="4B7B" data-bytes="97 46">—F</span> <span data-cp="4B7E" data-bytes="A0 E6"> æ</span> <span data-cp="4B8E" data-bytes="92 D7">’×</span> <span data-cp="4B90" data-bytes="96 75">–u</span> <span data-cp="4B93" data-bytes="93 D4">“Ô</span> <span data-cp="4B96" data-bytes="91 BB">‘»</span> <span data-cp="4B97" data-bytes="96 79">–y</span> <span data-cp="4B9D" data-bytes="9A 70">šp</span> <span data-cp="4BBD" data-bytes="96 78">–x</span> <span data-cp="4BBE" data-bytes="91 CD">‘Í</span> <span data-cp="4BC0" data-bytes="9C 4A">œJ</span> <span data-cp="4C04" data-bytes="A0 6F"> o</span> <span data-cp="4C07" data-bytes="A0 6A"> j</span> <span data-cp="4C0E" data-bytes="91 5F">‘_</span> <span data-cp="4C32" data-bytes="87 41">‡A</span> <span data-cp="4C3B" data-bytes="9F A5">Ÿ¥</span> <span data-cp="4C3E" data-bytes="89 BA">‰º</span> <span data-cp="4C40" data-bytes="87 4F">‡O</span> <span data-cp="4C47" data-bytes="87 4E">‡N</span> <span data-cp="4C57" data-bytes="87 55">‡U</span> <span data-cp="4C5B" data-bytes="9E CD">žÍ</span> <span data-cp="4C6D" data-bytes="9A 79">šy</span> <span data-cp="4C77" data-bytes="8C F2">Œò</span> <span data-cp="4C7B" data-bytes="8D 57">�W</span> <span data-cp="4C7D" data-bytes="9D CE">�Î</span> <span data-cp="4C81" data-bytes="8C D2">ŒÒ</span> <span data-cp="4C85" data-bytes="87 59">‡Y</span> <span data-cp="4CA4" data-bytes="9D 73">�s</span> <span data-cp="4CAE" data-bytes="96 B9">–¹</span> <span data-cp="4CB0" data-bytes="96 BC">–¼</span> <span data-cp="4CB7" data-bytes="9C D1">œÑ</span> <span data-cp="4CCD" data-bytes="89 B7">‰·</span> <span data-cp="4CE1" data-bytes="9E EE">žî</span> <span data-cp="4CE2" data-bytes="87 49">‡I</span> <span data-cp="4D07" data-bytes="87 5B">‡[</span> <span data-cp="4D09" data-bytes="9E C9">žÉ</span> <span data-cp="4D34" data-bytes="91 AE">‘®</span> <span data-cp="4D76" data-bytes="8D 58">�X</span> <span data-cp="4D77" data-bytes="87 46">‡F</span> <span data-cp="4D89" data-bytes="8D 56">�V</span> <span data-cp="4D91" data-bytes="9D 78">�x</span> <span data-cp="4D9C" data-bytes="9D 7B">�{</span> <span data-cp="4E04" data-bytes="9E B3">ž³</span> <span data-cp="4E1A" data-bytes="9E B2">ž²</span> <span data-cp="4E1C" data-bytes="9D D6">�Ö</span> <span data-cp="4E21" data-bytes="99 4F">™O</span> <span data-cp="4E24" data-bytes="89 CE">‰Î</span> <span data-cp="4E28" data-bytes="8B C0">‹À</span> <span data-cp="4E2A" data-bytes="9F C4">ŸÄ</span> <span data-cp="4E2C" data-bytes="8B D4">‹Ô</span> <span data-cp="4E2F" data-bytes="8C 72">Œr</span> <span data-cp="4E37" data-bytes="8B F9">‹ù</span> <span data-cp="4E3D" data-bytes="89 46">‰F</span> <span data-cp="4E5B" data-bytes="8B C6">‹Æ</span> <span data-cp="4E6A" data-bytes="9C 57">œW</span> <span data-cp="4E78" data-bytes="9A FB">šû</span> <span data-cp="4E80" data-bytes="89 D0">‰Ð</span> <span data-cp="4E81" data-bytes="89 CF">‰Ï</span> <span data-cp="4E87" data-bytes="89 D1">‰Ñ</span> <span data-cp="4E89" data-bytes="89 E2">‰â</span> <span data-cp="4E98" data-bytes="92 7E">’~</span> <span data-cp="4E9A" data-bytes="9D BA">�º</span> <span data-cp="4EA3" data-bytes="8C 6F">Œo</span> <span data-cp="4EBB" data-bytes="8B C7">‹Ç</span> <span data-cp="4EBC" data-bytes="92 6B">’k</span> <span data-cp="4EBF" data-bytes="89 D2">‰Ò</span> <span data-cp="4ECE" data-bytes="9F CF">ŸÏ</span> <span data-cp="4EEA" data-bytes="9D A9">�©</span> <span data-cp="4EEB" data-bytes="89 D3">‰Ó</span> <span data-cp="4EEE" data-bytes="99 E2">™â</span> <span data-cp="4EF8" data-bytes="92 67">’g</span> <span data-cp="4F03" data-bytes="92 A4">’¤</span> <span data-cp="4F17" data-bytes="8C 73">Œs</span> <span data-cp="4F1A" data-bytes="89 4E">‰N</span> <span data-cp="4F28" data-bytes="89 4F">‰O</span> <span data-cp="4F29" data-bytes="92 78">’x</span> <span data-cp="4F32" data-bytes="91 B6">‘¶</span> <span data-cp="4F37" data-bytes="89 D4">‰Ô</span> <span data-cp="4F39" data-bytes="9F D2">ŸÒ</span> <span data-cp="4F42" data-bytes="92 A7">’§</span> <span data-cp="4F45" data-bytes="95 A2">•¢</span> <span data-cp="4F4B" data-bytes="92 6E">’n</span> <span data-cp="4F72" data-bytes="96 EA">–ê</span> <span data-cp="4F8A" data-bytes="92 6F">’o</span> <span data-cp="4FA2" data-bytes="92 A3">’£</span> <span data-cp="4FA8" data-bytes="89 50">‰P</span> <span data-cp="4FB0" data-bytes="98 66">˜f</span> <span data-cp="4FB4" data-bytes="8C F8">Œø</span> <span data-cp="4FBB" data-bytes="9C 53">œS</span> <span data-cp="4FBD" data-bytes="89 D6">‰Ö</span> <span data-cp="4FC8" data-bytes="98 B2">˜²</span> <span data-cp="4FCC" data-bytes="92 AB">’«</span> <span data-cp="4FE4" data-bytes="96 DE">–Þ</span> <span data-cp="4FE5" data-bytes="92 AC">’¬</span> <span data-cp="4FF0" data-bytes="8C 70">Œp</span> <span data-cp="4FF2" data-bytes="9F 6E">Ÿn</span> <span data-cp="4FF9" data-bytes="8E F2">Žò</span> <span data-cp="4FFD" data-bytes="9F 6C">Ÿl</span> <span data-cp="5003" data-bytes="89 D8">‰Ø</span> <span data-cp="502E" data-bytes="92 A8">’¨</span> <span data-cp="5034" data-bytes="91 63">‘c</span> <span data-cp="503B" data-bytes="8C 40">Œ@</span> <span data-cp="5056" data-bytes="9F 73">Ÿs</span> <span data-cp="5058" data-bytes="92 AD">’­</span> <span data-cp="5066" data-bytes="9B E9">›é</span> <span data-cp="506C" data-bytes="92 A9">’©</span> <span data-cp="5081" data-bytes="92 AA">’ª</span> <span data-cp="5088" data-bytes="89 D9">‰Ù</span> <span data-cp="50A6" data-bytes="9F A8">Ÿ¨</span> <span data-cp="50BC" data-bytes="8C 71">Œq</span> <span data-cp="50CD" data-bytes="92 A1">’¡</span> <span data-cp="50D0" data-bytes="90 E3">�ã</span> <span data-cp="50D9" data-bytes="A0 A6"> ¦</span> <span data-cp="50DF" data-bytes="94 AB">”«</span> <span data-cp="50ED" data-bytes="9F CB">ŸË</span> <span data-cp="50F4" data-bytes="97 C4">—Ä</span> <span data-cp="50FC" data-bytes="92 AE">’®</span> <span data-cp="510D" data-bytes="92 A2">’¢</span> <span data-cp="512B" data-bytes="92 68">’h</span> <span data-cp="5156" data-bytes="89 51">‰Q</span> <span data-cp="5159" data-bytes="92 AF">’¯</span> <span data-cp="515B" data-bytes="92 B0">’°</span> <span data-cp="515D" data-bytes="92 B1">’±</span> <span data-cp="515E" data-bytes="92 B2">’²</span> <span data-cp="5174" data-bytes="89 52">‰R</span> <span data-cp="5179" data-bytes="94 5A">”Z</span> <span data-cp="5186" data-bytes="89 DD">‰Ý</span> <span data-cp="519A" data-bytes="9E 52">žR</span> <span data-cp="519C" data-bytes="89 53">‰S</span> <span data-cp="51A7" data-bytes="9E 55">žU</span> <span data-cp="51A8" data-bytes="92 BA">’º</span> <span data-cp="51AE" data-bytes="8C 5B">Œ[</span> <span data-cp="51B4" data-bytes="9A 68">šh</span> <span data-cp="51C3" data-bytes="92 BB">’»</span> <span data-cp="51D2" data-bytes="9B B4">›´</span> <span data-cp="51DB" data-bytes="89 DF">‰ß</span> <span data-cp="51E4" data-bytes="89 54">‰T</span> <span data-cp="51FC" data-bytes="89 E0">‰à</span> <span data-cp="51FE" data-bytes="9F 4F">ŸO</span> <span data-cp="5205" data-bytes="89 E1">‰á</span> <span data-cp="521F" data-bytes="9F CD">ŸÍ</span> <span data-cp="5220" data-bytes="A0 E7"> ç</span> <span data-cp="5227" data-bytes="89 A6">‰¦</span> <span data-cp="5234" data-bytes="9E FA">žú</span> <span data-cp="524F" data-bytes="87 BC">‡¼</span> <span data-cp="5259" data-bytes="92 C4">’Ä</span> <span data-cp="5260" data-bytes="9F 6F">Ÿo</span> <span data-cp="5268" data-bytes="8B B0">‹°</span> <span data-cp="5273" data-bytes="9F AC">Ÿ¬</span> <span data-cp="5279" data-bytes="89 E3">‰ã</span> <span data-cp="528F" data-bytes="9B D3">›Ó</span> <span data-cp="5290" data-bytes="89 E4">‰ä</span> <span data-cp="529A" data-bytes="9F D5">ŸÕ</span> <span data-cp="52A1" data-bytes="89 55">‰U</span> <span data-cp="52A4" data-bytes="92 C5">’Å</span> <span data-cp="52A8" data-bytes="89 56">‰V</span> <span data-cp="52CC" data-bytes="9E DC">žÜ</span> <span data-cp="52D1" data-bytes="9F 71">Ÿq</span> <span data-cp="52E1" data-bytes="92 C7">’Ç</span> <span data-cp="5301" data-bytes="9A 4C">šL</span> <span data-cp="5324" data-bytes="8C 68">Œh</span> <span data-cp="5327" data-bytes="89 E5">‰å</span> <span data-cp="532C" data-bytes="9F 7D">Ÿ}</span> <span data-cp="5332" data-bytes="A0 A9"> ©</span> <span data-cp="533B" data-bytes="89 57">‰W</span> <span data-cp="534E" data-bytes="89 58">‰X</span> <span data-cp="535D" data-bytes="8B E3">‹ã</span> <span data-cp="535F" data-bytes="8B 61">‹a</span> <span data-cp="5364" data-bytes="9A F1">šñ</span> <span data-cp="5367" data-bytes="9E B7">ž·</span> <span data-cp="537D" data-bytes="9E BA">žº</span> <span data-cp="53A2" data-bytes="9C E0">œà</span> <span data-cp="53A9" data-bytes="89 E7">‰ç</span> <span data-cp="53AA" data-bytes="A0 7A"> z</span> <span data-cp="53B0" data-bytes="89 E9">‰é</span> <span data-cp="53C2" data-bytes="89 EB">‰ë</span> <span data-cp="53CC" data-bytes="90 C8">�È</span> <span data-cp="53D0" data-bytes="92 DA">’Ú</span> <span data-cp="53D1" data-bytes="89 59">‰Y</span> <span data-cp="53D2" data-bytes="9C F5">œõ</span> <span data-cp="53D8" data-bytes="89 5A">‰Z</span> <span data-cp="53DA" data-bytes="9F A2">Ÿ¢</span> <span data-cp="53F7" data-bytes="8F AD">�­</span> <span data-cp="5414" data-bytes="96 EF">–ï</span> <span data-cp="5416" data-bytes="9D EC">�ì</span> <span data-cp="541A" data-bytes="9D CA">�Ê</span> <span data-cp="5423" data-bytes="89 EC">‰ì</span> <span data-cp="5432" data-bytes="9D E2">�â</span> <span data-cp="5434" data-bytes="8C 75">Œu</span> <span data-cp="544B" data-bytes="9E C0">žÀ</span> <span data-cp="544C" data-bytes="87 C5">‡Å</span> <span data-cp="544D" data-bytes="9E 56">žV</span> <span data-cp="5469" data-bytes="9F 79">Ÿy</span> <span data-cp="546A" data-bytes="9A C7">šÇ</span> <span data-cp="5485" data-bytes="98 A1">˜¡</span> <span data-cp="5493" data-bytes="89 F0">‰ð</span> <span data-cp="5494" data-bytes="9E 47">žG</span> <span data-cp="5497" data-bytes="9D F7">�÷</span> <span data-cp="549C" data-bytes="9F D3">ŸÓ</span> <span data-cp="549E" data-bytes="9A CA">šÊ</span> <span data-cp="54A3" data-bytes="89 F1">‰ñ</span> <span data-cp="54B2" data-bytes="8E 5A">ŽZ</span> <span data-cp="54B4" data-bytes="89 F2">‰ò</span> <span data-cp="54B9" data-bytes="89 F3">‰ó</span> <span data-cp="54CB" data-bytes="92 5D">’]</span> <span data-cp="54CC" data-bytes="8B 51">‹Q</span> <span data-cp="54CD" data-bytes="92 E0">’à</span> <span data-cp="54D0" data-bytes="89 F4">‰ô</span> <span data-cp="54DA" data-bytes="9F D4">ŸÔ</span> <span data-cp="54E3" data-bytes="8A 79">Šy</span> <span data-cp="54EF" data-bytes="89 F5">‰õ</span> <span data-cp="5502" data-bytes="97 A7">—§</span> <span data-cp="550D" data-bytes="93 BA">“º</span> <span data-cp="5513" data-bytes="9E 58">žX</span> <span data-cp="5518" data-bytes="89 F6">‰ö</span> <span data-cp="551E" data-bytes="9E 57">žW</span> <span data-cp="5523" data-bytes="89 F7">‰÷</span> <span data-cp="5525" data-bytes="8A 41">ŠA</span> <span data-cp="5528" data-bytes="89 F8">‰ø</span> <span data-cp="553F" data-bytes="89 FA">‰ú</span> <span data-cp="5569" data-bytes="9E 4E">žN</span> <span data-cp="556B" data-bytes="94 DC">”Ü</span> <span data-cp="5571" data-bytes="95 DA">•Ú</span> <span data-cp="5572" data-bytes="9D F8">�ø</span> <span data-cp="5573" data-bytes="9F 6A">Ÿj</span> <span data-cp="5579" data-bytes="8A B7">Š·</span> <span data-cp="5590" data-bytes="8A 46">ŠF</span> <span data-cp="55B0" data-bytes="91 48">‘H</span> <span data-cp="55B4" data-bytes="92 DE">’Þ</span> <span data-cp="55B9" data-bytes="8B 53">‹S</span> <span data-cp="55BA" data-bytes="9D F6">�ö</span> <span data-cp="55BC" data-bytes="9B DA">›Ú</span> <span data-cp="55C1" data-bytes="9D 7E">�~</span> <span data-cp="55D7" data-bytes="89 FD">‰ý</span> <span data-cp="55D8" data-bytes="99 E4">™ä</span> <span data-cp="55DE" data-bytes="9E 43">žC</span> <span data-cp="55EA" data-bytes="9D E9">�é</span> <span data-cp="55EC" data-bytes="8F 52">�R</span> <span data-cp="55F0" data-bytes="9D F5">�õ</span> <span data-cp="55F1" data-bytes="9D F0">�ð</span> <span data-cp="55F5" data-bytes="99 E7">™ç</span> <span data-cp="55FB" data-bytes="8B BD">‹½</span> <span data-cp="5605" data-bytes="9D EF">�ï</span> <span data-cp="5611" data-bytes="9F B7">Ÿ·</span> <span data-cp="561E" data-bytes="9D D0">�Ð</span> <span data-cp="5620" data-bytes="9F EB">Ÿë</span> <span data-cp="5621" data-bytes="8D A9">�©</span> <span data-cp="5622" data-bytes="9D CF">�Ï</span> <span data-cp="5623" data-bytes="98 E1">˜á</span> <span data-cp="5625" data-bytes="9D E5">�å</span> <span data-cp="562D" data-bytes="9D C8">�È</span> <span data-cp="5643" data-bytes="9D EB">�ë</span> <span data-cp="5650" data-bytes="9A A2">š¢</span> <span data-cp="5652" data-bytes="8A D6">ŠÖ</span> <span data-cp="5654" data-bytes="9A 5F">š_</span> <span data-cp="565D" data-bytes="9E F5">žõ</span> <span data-cp="5661" data-bytes="8F B7">�·</span> <span data-cp="567A" data-bytes="9A D2">šÒ</span> <span data-cp="567B" data-bytes="9E 6A">žj</span> <span data-cp="567C" data-bytes="9E E8">žè</span> <span data-cp="5689" data-bytes="8B BF">‹¿</span> <span data-cp="568A" data-bytes="91 C2">‘Â</span> <span data-cp="568B" data-bytes="9D 62">�b</span> <span data-cp="5692" data-bytes="92 60">’`</span> <span data-cp="569E" data-bytes="92 5E">’^</span> <span data-cp="569F" data-bytes="91 C1">‘Á</span> <span data-cp="56A1" data-bytes="8A C5">ŠÅ</span> <span data-cp="56A4" data-bytes="97 A3">—£</span> <span data-cp="56AF" data-bytes="8B 6C">‹l</span> <span data-cp="56B1" data-bytes="8D 7E">�~</span> <span data-cp="56B9" data-bytes="9C 54">œT</span> <span data-cp="56BF" data-bytes="9D BD">�½</span> <span data-cp="56D6" data-bytes="9C C5">œÅ</span> <span data-cp="56E2" data-bytes="89 5B">‰[</span> <span data-cp="56FB" data-bytes="87 65">‡e</span> <span data-cp="56FD" data-bytes="98 C7">˜Ç</span> <span data-cp="5715" data-bytes="9C EE">œî</span> <span data-cp="571D" data-bytes="92 E2">’â</span> <span data-cp="5732" data-bytes="94 A7">”§</span> <span data-cp="573D" data-bytes="8C CC">ŒÌ</span> <span data-cp="573F" data-bytes="9B D4">›Ô</span> <span data-cp="5754" data-bytes="99 E5">™å</span> <span data-cp="5757" data-bytes="9A C2">šÂ</span> <span data-cp="575B" data-bytes="91 FB">‘û</span> <span data-cp="575F" data-bytes="A0 73"> s</span> <span data-cp="5767" data-bytes="9F 72">Ÿr</span> <span data-cp="577A" data-bytes="9F CC">ŸÌ</span> <span data-cp="577E" data-bytes="98 A5">˜¥</span> <span data-cp="577F" data-bytes="92 E8">’è</span> <span data-cp="5788" data-bytes="9B BC">›¼</span> <span data-cp="578A" data-bytes="96 F3">–ó</span> <span data-cp="578D" data-bytes="92 E7">’ç</span> <span data-cp="579C" data-bytes="8B 7D">‹}</span> <span data-cp="57A1" data-bytes="9B F4">›ô</span> <span data-cp="57A7" data-bytes="9E F7">ž÷</span> <span data-cp="57AA" data-bytes="9E C1">žÁ</span> <span data-cp="57B3" data-bytes="87 C3">‡Ã</span> <span data-cp="57B4" data-bytes="99 6F">™o</span> <span data-cp="57BB" data-bytes="96 F1">–ñ</span> <span data-cp="57BE" data-bytes="8E 41">ŽA</span> <span data-cp="57C4" data-bytes="95 4A">•J</span> <span data-cp="57C8" data-bytes="97 E6">—æ</span> <span data-cp="57D7" data-bytes="96 F5">–õ</span> <span data-cp="57DD" data-bytes="92 E6">’æ</span> <span data-cp="57DE" data-bytes="9F 42">ŸB</span> <span data-cp="57EF" data-bytes="99 A9">™©</span> <span data-cp="5812" data-bytes="97 E5">—å</span> <span data-cp="5818" data-bytes="87 C8">‡È</span> <span data-cp="5822" data-bytes="96 7D">–}</span> <span data-cp="583A" data-bytes="99 A2">™¢</span> <span data-cp="5840" data-bytes="9A BB">š»</span> <span data-cp="5844" data-bytes="9A 65">še</span> <span data-cp="5847" data-bytes="94 4E">”N</span> <span data-cp="585F" data-bytes="99 DF">™ß</span> <span data-cp="5869" data-bytes="98 E3">˜ã</span> <span data-cp="586C" data-bytes="92 54">’T</span> <span data-cp="5872" data-bytes="96 7B">–{</span> <span data-cp="5873" data-bytes="8A AF">Š¯</span> <span data-cp="5892" data-bytes="8C 77">Œw</span> <span data-cp="5896" data-bytes="87 B0">‡°</span> <span data-cp="5899" data-bytes="8B AF">‹¯</span> <span data-cp="589A" data-bytes="9E BD">ž½</span> <span data-cp="58A7" data-bytes="9E E6">žæ</span> <span data-cp="58B0" data-bytes="8E E1">Žá</span> <span data-cp="58B5" data-bytes="9B 7D">›}</span> <span data-cp="58B6" data-bytes="9C 7E">œ~</span> <span data-cp="58CB" data-bytes="92 EA">’ê</span> <span data-cp="58D0" data-bytes="8C 78">Œx</span> <span data-cp="58F0" data-bytes="89 5C">‰\</span> <span data-cp="58F2" data-bytes="98 F0">˜ð</span> <span data-cp="58F3" data-bytes="96 F2">–ò</span> <span data-cp="5902" data-bytes="8B C1">‹Á</span> <span data-cp="5904" data-bytes="89 5D">‰]</span> <span data-cp="5905" data-bytes="89 DE">‰Þ</span> <span data-cp="5907" data-bytes="89 5E">‰^</span> <span data-cp="591D" data-bytes="87 68">‡h</span> <span data-cp="5932" data-bytes="89 5F">‰_</span> <span data-cp="5934" data-bytes="89 60">‰`</span> <span data-cp="5965" data-bytes="9B CD">›Í</span> <span data-cp="5975" data-bytes="9D D3">�Ó</span> <span data-cp="5989" data-bytes="98 4C">˜L</span> <span data-cp="5994" data-bytes="97 52">—R</span> <span data-cp="599A" data-bytes="95 C3">•Ã</span> <span data-cp="599F" data-bytes="9B B6">›¶</span> <span data-cp="59AC" data-bytes="9A B9">š¹</span> <span data-cp="59B0" data-bytes="97 B3">—³</span> <span data-cp="59B7" data-bytes="9F 74">Ÿt</span> <span data-cp="59B8" data-bytes="92 F1">’ñ</span> <span data-cp="59BF" data-bytes="8C FA">Œú</span> <span data-cp="59C4" data-bytes="97 DF">—ß</span> <span data-cp="59EB" data-bytes="98 77">˜w</span> <span data-cp="59EF" data-bytes="98 54">˜T</span> <span data-cp="59F0" data-bytes="95 C5">•Å</span> <span data-cp="59F8" data-bytes="9D 55">�U</span> <span data-cp="5A02" data-bytes="95 7E">•~</span> <span data-cp="5A0B" data-bytes="97 42">—B</span> <span data-cp="5A0D" data-bytes="94 E6">”æ</span> <span data-cp="5A12" data-bytes="92 F5">’õ</span> <span data-cp="5A1A" data-bytes="8C C5">ŒÅ</span> <span data-cp="5A21" data-bytes="92 FD">’ý</span> <span data-cp="5A27" data-bytes="9C 51">œQ</span> <span data-cp="5A2A" data-bytes="94 E9">”é</span> <span data-cp="5A2B" data-bytes="98 5C">˜\</span> <span data-cp="5A2C" data-bytes="92 F0">’ð</span> <span data-cp="5A3D" data-bytes="94 4C">”L</span> <span data-cp="5A45" data-bytes="91 6B">‘k</span> <span data-cp="5A54" data-bytes="8B 78">‹x</span> <span data-cp="5A59" data-bytes="94 E2">”â</span> <span data-cp="5A61" data-bytes="98 4F">˜O</span> <span data-cp="5A67" data-bytes="9C D0">œÐ</span> <span data-cp="5A68" data-bytes="92 71">’q</span> <span data-cp="5A6B" data-bytes="93 65">“e</span> <span data-cp="5A6E" data-bytes="98 5B">˜[</span> <span data-cp="5A71" data-bytes="98 50">˜P</span> <span data-cp="5A79" data-bytes="97 BC">—¼</span> <span data-cp="5A7E" data-bytes="92 F3">’ó</span> <span data-cp="5A81" data-bytes="93 40">“@</span> <span data-cp="5A82" data-bytes="98 4D">˜M</span> <span data-cp="5A86" data-bytes="95 72">•r</span> <span data-cp="5A99" data-bytes="92 EB">’ë</span> <span data-cp="5AA1" data-bytes="97 B7">—·</span> <span data-cp="5AA4" data-bytes="87 6F">‡o</span> <span data-cp="5AC3" data-bytes="90 A7">�§</span> <span data-cp="5ACE" data-bytes="97 41">—A</span> <span data-cp="5ACF" data-bytes="92 F4">’ô</span> <span data-cp="5AD1" data-bytes="87 72">‡r</span> <span data-cp="5AE4" data-bytes="95 77">•w</span> <span data-cp="5AF0" data-bytes="9E E2">žâ</span> <span data-cp="5AF2" data-bytes="8F 78">�x</span> <span data-cp="5AFE" data-bytes="96 72">–r</span> <span data-cp="5B0D" data-bytes="9E B5">žµ</span> <span data-cp="5B11" data-bytes="96 4B">–K</span> <span data-cp="5B15" data-bytes="8C AC">Œ¬</span> <span data-cp="5B1F" data-bytes="A0 FA"> ú</span> <span data-cp="5B28" data-bytes="96 FC">–ü</span> <span data-cp="5B2B" data-bytes="95 75">•u</span> <span data-cp="5B41" data-bytes="90 DA">�Ú</span> <span data-cp="5B44" data-bytes="93 67">“g</span> <span data-cp="5B4A" data-bytes="90 DF">�ß</span> <span data-cp="5B4F" data-bytes="93 54">“T</span> <span data-cp="5B66" data-bytes="89 61">‰a</span> <span data-cp="5B68" data-bytes="8B B4">‹´</span> <span data-cp="5B6D" data-bytes="9D C0">�À</span> <span data-cp="5B74" data-bytes="8E 48">ŽH</span> <span data-cp="5B90" data-bytes="9E 67">žg</span> <span data-cp="5B96" data-bytes="8C D9">ŒÙ</span> <span data-cp="5B9E" data-bytes="89 62">‰b</span> <span data-cp="5B9F" data-bytes="89 63">‰c</span> <span data-cp="5BB7" data-bytes="87 73">‡s</span> <span data-cp="5BC3" data-bytes="9F 6B">Ÿk</span> <span data-cp="5BDB" data-bytes="87 6D">‡m</span> <span data-cp="5C10" data-bytes="9C BC">œ¼</span> <span data-cp="5C1C" data-bytes="8B 5D">‹]</span> <span data-cp="5C1E" data-bytes="93 4C">“L</span> <span data-cp="5C20" data-bytes="9A E2">šâ</span> <span data-cp="5C23" data-bytes="8B C9">‹É</span> <span data-cp="5C4A" data-bytes="9F C9">ŸÉ</span> <span data-cp="5C53" data-bytes="9F 44">ŸD</span> <span data-cp="5C5E" data-bytes="98 ED">˜í</span> <span data-cp="5C78" data-bytes="8C E9">Œé</span> <span data-cp="5C99" data-bytes="8D F2">�ò</span> <span data-cp="5C9A" data-bytes="89 64">‰d</span> <span data-cp="5C9E" data-bytes="93 4D">“M</span> <span data-cp="5CC1" data-bytes="A0 F2"> ò</span> <span data-cp="5CC2" data-bytes="98 68">˜h</span> <span data-cp="5CD1" data-bytes="9F 58">ŸX</span> <span data-cp="5CD5" data-bytes="8C E6">Œæ</span> <span data-cp="5CE5" data-bytes="8D 73">�s</span> <span data-cp="5CF5" data-bytes="8C 48">ŒH</span> <span data-cp="5CFC" data-bytes="87 74">‡t</span> <span data-cp="5D15" data-bytes="8D A8">�¨</span> <span data-cp="5D2C" data-bytes="9C 75">œu</span> <span data-cp="5D2F" data-bytes="98 78">˜x</span> <span data-cp="5D3E" data-bytes="8D 60">�`</span> <span data-cp="5D48" data-bytes="8D 61">�a</span> <span data-cp="5D56" data-bytes="8D 62">�b</span> <span data-cp="5D57" data-bytes="A0 A1"> ¡</span> <span data-cp="5D5B" data-bytes="9C 40">œ@</span> <span data-cp="5D70" data-bytes="98 AD">˜­</span> <span data-cp="5D74" data-bytes="9E EA">žê</span> <span data-cp="5D78" data-bytes="8C EC">Œì</span> <span data-cp="5D7B" data-bytes="8C D4">ŒÔ</span> <span data-cp="5D85" data-bytes="9C EB">œë</span> <span data-cp="5D8E" data-bytes="9F 51">ŸQ</span> <span data-cp="5DA4" data-bytes="8D 65">�e</span> <span data-cp="5DAB" data-bytes="9C F1">œñ</span> <span data-cp="5DB9" data-bytes="8D 66">�f</span> <span data-cp="5DC1" data-bytes="96 54">–T</span> <span data-cp="5DF5" data-bytes="9F CE">ŸÎ</span> <span data-cp="5E0B" data-bytes="9A E4">šä</span> <span data-cp="5E12" data-bytes="9F 75">Ÿu</span> <span data-cp="5E42" data-bytes="8D 69">�i</span> <span data-cp="5E48" data-bytes="93 4F">“O</span> <span data-cp="5E5E" data-bytes="93 4E">“N</span> <span data-cp="5E86" data-bytes="89 65">‰e</span> <span data-cp="5E92" data-bytes="8C 7A">Œz</span> <span data-cp="5E99" data-bytes="8C 7B">Œ{</span> <span data-cp="5EBD" data-bytes="8D 6A">�j</span> <span data-cp="5ECD" data-bytes="93 53">“S</span> <span data-cp="5ED0" data-bytes="9D FB">�û</span> <span data-cp="5EF8" data-bytes="90 59">�Y</span> <span data-cp="5F0C" data-bytes="93 61">“a</span> <span data-cp="5F0E" data-bytes="93 62">“b</span> <span data-cp="5F25" data-bytes="8D 6B">�k</span> <span data-cp="5F3B" data-bytes="8C FE">Œþ</span> <span data-cp="5F4D" data-bytes="95 B8">•¸</span> <span data-cp="5F51" data-bytes="8B CA">‹Ê</span> <span data-cp="5F5C" data-bytes="98 7A">˜z</span> <span data-cp="5F83" data-bytes="8D 6C">�l</span> <span data-cp="5FB1" data-bytes="9B 70">›p</span> <span data-cp="5FBA" data-bytes="A0 51"> Q</span> <span data-cp="5FC2" data-bytes="8C 7C">Œ|</span> <span data-cp="5FC4" data-bytes="8B CB">‹Ë</span> <span data-cp="5FDB" data-bytes="93 6E">“n</span> <span data-cp="603B" data-bytes="89 66">‰f</span> <span data-cp="6062" data-bytes="9E A9">ž©</span> <span data-cp="6075" data-bytes="93 7A">“z</span> <span data-cp="6077" data-bytes="A0 E0"> à</span> <span data-cp="607E" data-bytes="93 6B">“k</span> <span data-cp="60A4" data-bytes="A0 DC"> Ü</span> <span data-cp="60A7" data-bytes="94 68">”h</span> <span data-cp="60D7" data-bytes="8D 71">�q</span> <span data-cp="60DE" data-bytes="9B EC">›ì</span> <span data-cp="60E3" data-bytes="99 BA">™º</span> <span data-cp="60E7" data-bytes="9A D0">šÐ</span> <span data-cp="60E8" data-bytes="9A 61">ša</span> <span data-cp="60E9" data-bytes="A0 E5"> å</span> <span data-cp="60FD" data-bytes="A0 5B"> [</span> <span data-cp="6107" data-bytes="96 AC">–¬</span> <span data-cp="610C" data-bytes="97 40">—@</span> <span data-cp="6119" data-bytes="9E F1">žñ</span> <span data-cp="6122" data-bytes="8C 4D">ŒM</span> <span data-cp="6130" data-bytes="9F 7E">Ÿ~</span> <span data-cp="613D" data-bytes="8D 72">�r</span> <span data-cp="6150" data-bytes="96 A9">–©</span> <span data-cp="6159" data-bytes="A0 6E"> n</span> <span data-cp="616F" data-bytes="A0 74"> t</span> <span data-cp="617D" data-bytes="A0 71"> q</span> <span data-cp="6195" data-bytes="9C 50">œP</span> <span data-cp="6198" data-bytes="93 79">“y</span> <span data-cp="6199" data-bytes="93 78">“x</span> <span data-cp="619C" data-bytes="A0 DD"> Ý</span> <span data-cp="61B7" data-bytes="8D 75">�u</span> <span data-cp="61B9" data-bytes="8D 76">�v</span> <span data-cp="61C0" data-bytes="93 74">“t</span> <span data-cp="61CF" data-bytes="8D 77">�w</span> <span data-cp="61DA" data-bytes="90 C3">�Ã</span> <span data-cp="61E2" data-bytes="A0 79"> y</span> <span data-cp="622C" data-bytes="8D 79">�y</span> <span data-cp="6237" data-bytes="8B FC">‹ü</span> <span data-cp="6239" data-bytes="A0 76"> v</span> <span data-cp="624C" data-bytes="8B CD">‹Í</span> <span data-cp="6268" data-bytes="9F 5A">ŸZ</span> <span data-cp="6282" data-bytes="9F F4">Ÿô</span> <span data-cp="6285" data-bytes="9F BA">Ÿº</span> <span data-cp="6290" data-bytes="8D 7A">�z</span> <span data-cp="629D" data-bytes="9E 45">žE</span> <span data-cp="62A4" data-bytes="93 B0">“°</span> <span data-cp="62A6" data-bytes="A0 75"> u</span> <span data-cp="62C1" data-bytes="87 DD">‡Ý</span> <span data-cp="62C3" data-bytes="9B 46">›F</span> <span data-cp="62CE" data-bytes="A0 77"> w</span> <span data-cp="62D0" data-bytes="9D C4">�Ä</span> <span data-cp="62E5" data-bytes="8D 7B">�{</span> <span data-cp="6318" data-bytes="8D 7C">�|</span> <span data-cp="632E" data-bytes="9E D6">žÖ</span> <span data-cp="6331" data-bytes="93 AC">“¬</span> <span data-cp="6335" data-bytes="9F 5B">Ÿ[</span> <span data-cp="6337" data-bytes="93 A9">“©</span> <span data-cp="6364" data-bytes="A0 7C"> |</span> <span data-cp="6379" data-bytes="8A C1">ŠÁ</span> <span data-cp="637F" data-bytes="9F B4">Ÿ´</span> <span data-cp="63B9" data-bytes="9E 4C">žL</span> <span data-cp="63C1" data-bytes="8F C5">�Å</span> <span data-cp="63D1" data-bytes="93 AD">“­</span> <span data-cp="63DE" data-bytes="9D C3">�Ã</span> <span data-cp="63E2" data-bytes="8D A2">�¢</span> <span data-cp="63E6" data-bytes="9D 4A">�J</span> <span data-cp="63FB" data-bytes="8D A3">�£</span> <span data-cp="63FC" data-bytes="9E 4B">žK</span> <span data-cp="63FE" data-bytes="9E 4D">žM</span> <span data-cp="6407" data-bytes="8D A4">�¤</span> <span data-cp="6432" data-bytes="8A FD">Šý</span> <span data-cp="643B" data-bytes="93 B2">“²</span> <span data-cp="645A" data-bytes="8D A5">�¥</span> <span data-cp="6471" data-bytes="93 A1">“¡</span> <span data-cp="647C" data-bytes="8A C6">ŠÆ</span> <span data-cp="648D" data-bytes="8A 5B">Š[</span> <span data-cp="6491" data-bytes="89 4D">‰M</span> <span data-cp="64B4" data-bytes="8A 78">Šx</span> <span data-cp="64B6" data-bytes="93 AB">“«</span> <span data-cp="64C0" data-bytes="8D A7">�§</span> <span data-cp="64D3" data-bytes="9F 45">ŸE</span> <span data-cp="64DD" data-bytes="8A 56">ŠV</span> <span data-cp="64E7" data-bytes="8E E6">Žæ</span> <span data-cp="64EA" data-bytes="8A A4">Š¤</span> <span data-cp="650A" data-bytes="89 43">‰C</span> <span data-cp="6511" data-bytes="93 F3">“ó</span> <span data-cp="651F" data-bytes="9E A2">ž¢</span> <span data-cp="6530" data-bytes="9D C7">�Ç</span> <span data-cp="6535" data-bytes="8B CE">‹Î</span> <span data-cp="656B" data-bytes="93 B3">“³</span> <span data-cp="6586" data-bytes="8D AC">�¬</span> <span data-cp="6589" data-bytes="89 67">‰g</span> <span data-cp="658B" data-bytes="8C 7E">Œ~</span> <span data-cp="65BE" data-bytes="9C F3">œó</span> <span data-cp="65D4" data-bytes="95 BB">•»</span> <span data-cp="65FF" data-bytes="8D AE">�®</span> <span data-cp="661E" data-bytes="93 DB">“Û</span> <span data-cp="6630" data-bytes="93 D5">“Õ</span> <span data-cp="6648" data-bytes="9B 71">›q</span> <span data-cp="664D" data-bytes="87 64">‡d</span> <span data-cp="6653" data-bytes="8D AF">�¯</span> <span data-cp="6660" data-bytes="87 B5">‡µ</span> <span data-cp="6663" data-bytes="93 D8">“Ø</span> <span data-cp="666B" data-bytes="93 D3">“Ó</span> <span data-cp="667D" data-bytes="8E 76">Žv</span> <span data-cp="668E" data-bytes="93 D1">“Ñ</span> <span data-cp="6692" data-bytes="8D B1">�±</span> <span data-cp="669A" data-bytes="98 59">˜Y</span> <span data-cp="66B6" data-bytes="9C BF">œ¿</span> <span data-cp="66BF" data-bytes="9B 72">›r</span> <span data-cp="66CE" data-bytes="93 BE">“¾</span> <span data-cp="66E7" data-bytes="8C DB">ŒÛ</span> <span data-cp="66F1" data-bytes="9D F1">�ñ</span> <span data-cp="670C" data-bytes="A0 BB"> »</span> <span data-cp="670E" data-bytes="9B 7E">›~</span> <span data-cp="6716" data-bytes="8D B3">�³</span> <span data-cp="6719" data-bytes="8C 52">ŒR</span> <span data-cp="671E" data-bytes="9A E8">šè</span> <span data-cp="6725" data-bytes="8E DC">ŽÜ</span> <span data-cp="6736" data-bytes="9C F9">œù</span> <span data-cp="6761" data-bytes="98 E7">˜ç</span> <span data-cp="676B" data-bytes="8C CA">ŒÊ</span> <span data-cp="676E" data-bytes="87 75">‡u</span> <span data-cp="6782" data-bytes="87 BA">‡º</span> <span data-cp="678F" data-bytes="93 E5">“å</span> <span data-cp="67A0" data-bytes="9A 59">šY</span> <span data-cp="67A4" data-bytes="8D B5">�µ</span> <span data-cp="67BF" data-bytes="8F 7D">�}</span> <span data-cp="67D6" data-bytes="95 47">•G</span> <span data-cp="67F9" data-bytes="92 50">’P</span> <span data-cp="67FE" data-bytes="89 68">‰h</span> <span data-cp="6800" data-bytes="8D B6">�¶</span> <span data-cp="6802" data-bytes="A0 7D"> }</span> <span data-cp="6803" data-bytes="98 FC">˜ü</span> <span data-cp="6804" data-bytes="89 69">‰i</span> <span data-cp="6810" data-bytes="92 56">’V</span> <span data-cp="681E" data-bytes="93 E8">“è</span> <span data-cp="6836" data-bytes="9C E3">œã</span> <span data-cp="6847" data-bytes="96 40">–@</span> <span data-cp="684A" data-bytes="8D B8">�¸</span> <span data-cp="6855" data-bytes="9B 4A">›J</span> <span data-cp="6856" data-bytes="8F B9">�¹</span> <span data-cp="6865" data-bytes="89 6A">‰j</span> <span data-cp="6884" data-bytes="8D B9">�¹</span> <span data-cp="6888" data-bytes="91 7E">‘~</span> <span data-cp="6898" data-bytes="93 F4">“ô</span> <span data-cp="68B6" data-bytes="93 E7">“ç</span> <span data-cp="68B9" data-bytes="97 EF">—ï</span> <span data-cp="68C5" data-bytes="96 A5">–¥</span> <span data-cp="6909" data-bytes="8D BD">�½</span> <span data-cp="6918" data-bytes="9B A1">›¡</span> <span data-cp="6919" data-bytes="8C A2">Œ¢</span> <span data-cp="691A" data-bytes="9A B7">š·</span> <span data-cp="691B" data-bytes="8E FC">Žü</span> <span data-cp="692C" data-bytes="9F A1">Ÿ¡</span> <span data-cp="6943" data-bytes="8D BE">�¾</span> <span data-cp="6946" data-bytes="89 A4">‰¤</span> <span data-cp="6955" data-bytes="9A D9">šÙ</span> <span data-cp="6964" data-bytes="8D C0">�À</span> <span data-cp="6967" data-bytes="97 F0">—ð</span> <span data-cp="6972" data-bytes="93 B4">“´</span> <span data-cp="6980" data-bytes="9F A7">Ÿ§</span> <span data-cp="6985" data-bytes="8D C2">�Â</span> <span data-cp="698A" data-bytes="99 B6">™¶</span> <span data-cp="699F" data-bytes="8D C1">�Á</span> <span data-cp="69A2" data-bytes="8E 46">ŽF</span> <span data-cp="69B2" data-bytes="A0 D1"> Ñ</span> <span data-cp="69C0" data-bytes="9F CA">ŸÊ</span> <span data-cp="69D1" data-bytes="92 CF">’Ï</span> <span data-cp="69D5" data-bytes="9C F4">œô</span> <span data-cp="69D6" data-bytes="8D C4">�Ä</span> <span data-cp="69E9" data-bytes="9B 4C">›L</span> <span data-cp="6A03" data-bytes="9C DE">œÞ</span> <span data-cp="6A0C" data-bytes="98 6C">˜l</span> <span data-cp="6A1A" data-bytes="97 F9">—ù</span> <span data-cp="6A1C" data-bytes="95 58">•X</span> <span data-cp="6A29" data-bytes="87 B6">‡¶</span> <span data-cp="6A2B" data-bytes="98 5E">˜^</span> <span data-cp="6A2D" data-bytes="94 CD">”Í</span> <span data-cp="6A33" data-bytes="93 EE">“î</span> <span data-cp="6A43" data-bytes="8C A3">Œ£</span> <span data-cp="6A4C" data-bytes="93 F5">“õ</span> <span data-cp="6A52" data-bytes="93 EF">“ï</span> <span data-cp="6A53" data-bytes="8E EA">Žê</span> <span data-cp="6A57" data-bytes="8F 5B">�[</span> <span data-cp="6A63" data-bytes="8C 5E">Œ^</span> <span data-cp="6A65" data-bytes="8D C6">�Æ</span> <span data-cp="6A71" data-bytes="8D C8">�È</span> <span data-cp="6A74" data-bytes="8D C7">�Ç</span> <span data-cp="6A7A" data-bytes="93 F7">“÷</span> <span data-cp="6A82" data-bytes="8D C9">�É</span> <span data-cp="6A8F" data-bytes="96 70">–p</span> <span data-cp="6A99" data-bytes="8D CB">�Ë</span> <span data-cp="6AA7" data-bytes="8F 65">�e</span> <span data-cp="6AAB" data-bytes="8D CD">�Í</span> <span data-cp="6AB1" data-bytes="9D A8">�¨</span> <span data-cp="6AB2" data-bytes="94 F9">”ù</span> <span data-cp="6AB5" data-bytes="8D CE">�Î</span> <span data-cp="6ABE" data-bytes="93 EA">“ê</span> <span data-cp="6AC9" data-bytes="93 F0">“ð</span> <span data-cp="6ACA" data-bytes="9F B6">Ÿ¶</span> <span data-cp="6AD4" data-bytes="8D CF">�Ï</span> <span data-cp="6AD8" data-bytes="97 63">—c</span> <span data-cp="6AF6" data-bytes="8D D0">�Ð</span> <span data-cp="6B05" data-bytes="93 F1">“ñ</span> <span data-cp="6B52" data-bytes="9F DB">ŸÛ</span> <span data-cp="6B57" data-bytes="93 F8">“ø</span> <span data-cp="6B6F" data-bytes="8B F7">‹÷</span> <span data-cp="6B7A" data-bytes="8B CF">‹Ï</span> <span data-cp="6B81" data-bytes="8D D1">�Ñ</span> <span data-cp="6BC1" data-bytes="8D D2">�Ò</span> <span data-cp="6BEA" data-bytes="8D D3">�Ó</span> <span data-cp="6BFA" data-bytes="9F E7">Ÿç</span> <span data-cp="6C1C" data-bytes="90 BD">�½</span> <span data-cp="6C31" data-bytes="9F D0">ŸÐ</span> <span data-cp="6C35" data-bytes="8B D0">‹Ð</span> <span data-cp="6C39" data-bytes="9C AE">œ®</span> <span data-cp="6C3A" data-bytes="8B D1">‹Ñ</span> <span data-cp="6C3D" data-bytes="8A DB">ŠÛ</span> <span data-cp="6C4A" data-bytes="9E FD">žý</span> <span data-cp="6C58" data-bytes="95 CE">•Î</span> <span data-cp="6C75" data-bytes="8D D4">�Ô</span> <span data-cp="6C7F" data-bytes="8E E3">Žã</span> <span data-cp="6C9F" data-bytes="90 76">�v</span> <span data-cp="6CA2" data-bytes="98 C6">˜Æ</span> <span data-cp="6CAA" data-bytes="8D D5">�Õ</span> <span data-cp="6CAF" data-bytes="97 D1">—Ñ</span> <span data-cp="6CB2" data-bytes="9E B6">ž¶</span> <span data-cp="6CCE" data-bytes="A0 42"> B</span> <span data-cp="6CDF" data-bytes="98 73">˜s</span> <span data-cp="6CEA" data-bytes="9F FC">Ÿü</span> <span data-cp="6CFF" data-bytes="8C A5">Œ¥</span> <span data-cp="6D02" data-bytes="8D D7">�×</span> <span data-cp="6D05" data-bytes="92 FB">’û</span> <span data-cp="6D06" data-bytes="8D D8">�Ø</span> <span data-cp="6D24" data-bytes="94 4F">”O</span> <span data-cp="6D26" data-bytes="8D D9">�Ù</span> <span data-cp="6D4E" data-bytes="89 6B">‰k</span> <span data-cp="6D57" data-bytes="97 CE">—Î</span> <span data-cp="6D67" data-bytes="94 47">”G</span> <span data-cp="6D72" data-bytes="92 B7">’·</span> <span data-cp="6D81" data-bytes="8D DA">�Ú</span> <span data-cp="6D8F" data-bytes="9C 5A">œZ</span> <span data-cp="6DA4" data-bytes="8D DC">�Ü</span> <span data-cp="6DA5" data-bytes="94 44">”D</span> <span data-cp="6DB1" data-bytes="8D DD">�Ý</span> <span data-cp="6DB9" data-bytes="A0 D6"> Ö</span> <span data-cp="6DFE" data-bytes="8C 41">ŒA</span> <span data-cp="6E02" data-bytes="97 D5">—Õ</span> <span data-cp="6E04" data-bytes="94 4A">”J</span> <span data-cp="6E0A" data-bytes="94 4D">”M</span> <span data-cp="6E0F" data-bytes="97 CB">—Ë</span> <span data-cp="6E15" data-bytes="8D DE">�Þ</span> <span data-cp="6E18" data-bytes="8D DF">�ß</span> <span data-cp="6E29" data-bytes="8D E0">�à</span> <span data-cp="6E57" data-bytes="8C DD">ŒÝ</span> <span data-cp="6E76" data-bytes="92 B3">’³</span> <span data-cp="6E86" data-bytes="8D E1">�á</span> <span data-cp="6E8B" data-bytes="95 D3">•Ó</span> <span data-cp="6E9A" data-bytes="89 C1">‰Á</span> <span data-cp="6EB8" data-bytes="9C B7">œ·</span> <span data-cp="6EBB" data-bytes="8D E3">�ã</span> <span data-cp="6EDA" data-bytes="8D E5">�å</span> <span data-cp="6EDD" data-bytes="89 47">‰G</span> <span data-cp="6EE2" data-bytes="8D E4">�ä</span> <span data-cp="6EE8" data-bytes="8D E7">�ç</span> <span data-cp="6EE9" data-bytes="8D E8">�è</span> <span data-cp="6F0B" data-bytes="94 45">”E</span> <span data-cp="6F0C" data-bytes="97 D6">—Ö</span> <span data-cp="6F17" data-bytes="98 44">˜D</span> <span data-cp="6F24" data-bytes="8D E9">�é</span> <span data-cp="6F34" data-bytes="8D EA">�ê</span> <span data-cp="6F56" data-bytes="9D A7">�§</span> <span data-cp="6F79" data-bytes="95 D2">•Ò</span> <span data-cp="6F81" data-bytes="8D ED">�í</span> <span data-cp="6FB5" data-bytes="9C DC">œÜ</span> <span data-cp="6FB6" data-bytes="9B F6">›ö</span> <span data-cp="6FBB" data-bytes="95 CF">•Ï</span> <span data-cp="6FBE" data-bytes="8D EE">�î</span> <span data-cp="6FD9" data-bytes="96 EC">–ì</span> <span data-cp="6FDA" data-bytes="96 EB">–ë</span> <span data-cp="6FF6" data-bytes="90 B6">�¶</span> <span data-cp="7003" data-bytes="98 AB">˜«</span> <span data-cp="701E" data-bytes="96 ED">–í</span> <span data-cp="702C" data-bytes="8D F4">�ô</span> <span data-cp="704D" data-bytes="8C 67">Œg</span> <span data-cp="7050" data-bytes="8D F6">�ö</span> <span data-cp="7054" data-bytes="8D F7">�÷</span> <span data-cp="705C" data-bytes="8F FA">�ú</span> <span data-cp="7067" data-bytes="97 D0">—Ð</span> <span data-cp="706C" data-bytes="8B D2">‹Ò</span> <span data-cp="706E" data-bytes="87 DE">‡Þ</span> <span data-cp="706F" data-bytes="8D F8">�ø</span> <span data-cp="7075" data-bytes="90 D9">�Ù</span> <span data-cp="7077" data-bytes="8C 47">ŒG</span> <span data-cp="707F" data-bytes="8D F9">�ù</span> <span data-cp="7089" data-bytes="8D FA">�ú</span> <span data-cp="708F" data-bytes="90 A6">�¦</span> <span data-cp="70A0" data-bytes="99 70">™p</span> <span data-cp="70A3" data-bytes="91 EB">‘ë</span> <span data-cp="70A5" data-bytes="97 70">—p</span> <span data-cp="70A6" data-bytes="98 6F">˜o</span> <span data-cp="70B9" data-bytes="98 F2">˜ò</span> <span data-cp="70BB" data-bytes="9A FC">šü</span> <span data-cp="70BC" data-bytes="89 6C">‰l</span> <span data-cp="70C0" data-bytes="99 5E">™^</span> <span data-cp="70C4" data-bytes="95 BD">•½</span> <span data-cp="70D0" data-bytes="91 E6">‘æ</span> <span data-cp="70F1" data-bytes="94 54">”T</span> <span data-cp="70F5" data-bytes="99 B8">™¸</span> <span data-cp="70FE" data-bytes="97 E9">—é</span> <span data-cp="7105" data-bytes="93 46">“F</span> <span data-cp="711D" data-bytes="98 63">˜c</span> <span data-cp="7129" data-bytes="95 BC">•¼</span> <span data-cp="7133" data-bytes="98 70">˜p</span> <span data-cp="7134" data-bytes="96 F6">–ö</span> <span data-cp="7135" data-bytes="8E A9">Ž©</span> <span data-cp="713B" data-bytes="94 51">”Q</span> <span data-cp="713E" data-bytes="8E 43">ŽC</span> <span data-cp="7140" data-bytes="8B 5A">‹Z</span> <span data-cp="7151" data-bytes="9B F5">›õ</span> <span data-cp="7157" data-bytes="8C EE">Œî</span> <span data-cp="7162" data-bytes="A0 DF"> ß</span> <span data-cp="716B" data-bytes="97 7E">—~</span> <span data-cp="7171" data-bytes="9B D5">›Õ</span> <span data-cp="7173" data-bytes="9A C3">šÃ</span> <span data-cp="7175" data-bytes="97 C8">—È</span> <span data-cp="7176" data-bytes="A0 DB"> Û</span> <span data-cp="7177" data-bytes="91 D0">‘Ð</span> <span data-cp="717A" data-bytes="9F E4">Ÿä</span> <span data-cp="717C" data-bytes="8F DD">�Ý</span> <span data-cp="717E" data-bytes="91 E9">‘é</span> <span data-cp="7188" data-bytes="98 E0">˜à</span> <span data-cp="718C" data-bytes="92 CA">’Ê</span> <span data-cp="718E" data-bytes="98 57">˜W</span> <span data-cp="7191" data-bytes="8C 51">ŒQ</span> <span data-cp="7198" data-bytes="9B 49">›I</span> <span data-cp="71A2" data-bytes="9D 76">�v</span> <span data-cp="71A3" data-bytes="9E AF">ž¯</span> <span data-cp="71AD" data-bytes="9C CC">œÌ</span> <span data-cp="71B7" data-bytes="8D F1">�ñ</span> <span data-cp="71D1" data-bytes="8E 53">ŽS</span> <span data-cp="71DF" data-bytes="9C 62">œb</span> <span data-cp="71EB" data-bytes="96 F9">–ù</span> <span data-cp="71F5" data-bytes="98 BF">˜¿</span> <span data-cp="71F6" data-bytes="9E 49">žI</span> <span data-cp="7200" data-bytes="8C A7">Œ§</span> <span data-cp="7201" data-bytes="9B 76">›v</span> <span data-cp="7209" data-bytes="9B CA">›Ê</span> <span data-cp="720F" data-bytes="92 DC">’Ü</span> <span data-cp="7216" data-bytes="91 CC">‘Ì</span> <span data-cp="7217" data-bytes="91 E2">‘â</span> <span data-cp="7225" data-bytes="87 5F">‡_</span> <span data-cp="722B" data-bytes="8B D3">‹Ó</span> <span data-cp="7250" data-bytes="94 55">”U</span> <span data-cp="725C" data-bytes="8D BF">�¿</span> <span data-cp="7266" data-bytes="9E 78">žx</span> <span data-cp="7287" data-bytes="94 56">”V</span> <span data-cp="728F" data-bytes="9D 61">�a</span> <span data-cp="7294" data-bytes="94 57">”W</span> <span data-cp="729F" data-bytes="99 66">™f</span> <span data-cp="72AD" data-bytes="8B D5">‹Õ</span> <span data-cp="72B2" data-bytes="A0 69"> i</span> <span data-cp="72CD" data-bytes="98 B4">˜´</span> <span data-cp="72E2" data-bytes="A0 49"> I</span> <span data-cp="7302" data-bytes="A0 4C"> L</span> <span data-cp="7304" data-bytes="9E 65">že</span> <span data-cp="7310" data-bytes="98 B5">˜µ</span> <span data-cp="732A" data-bytes="99 75">™u</span> <span data-cp="732C" data-bytes="A0 65"> e</span> <span data-cp="7338" data-bytes="98 B7">˜·</span> <span data-cp="7339" data-bytes="98 B8">˜¸</span> <span data-cp="7341" data-bytes="98 BA">˜º</span> <span data-cp="7348" data-bytes="98 BB">˜»</span> <span data-cp="734F" data-bytes="9F BC">Ÿ¼</span> <span data-cp="7371" data-bytes="A0 4A"> J</span> <span data-cp="7374" data-bytes="9E C7">žÇ</span> <span data-cp="738C" data-bytes="8C A9">Œ©</span> <span data-cp="738F" data-bytes="98 AE">˜®</span> <span data-cp="7398" data-bytes="92 D6">’Ö</span> <span data-cp="739E" data-bytes="91 D4">‘Ô</span> <span data-cp="73BA" data-bytes="8C 53">ŒS</span> <span data-cp="73C4" data-bytes="87 BF">‡¿</span> <span data-cp="73D0" data-bytes="94 C5">”Å</span> <span data-cp="73E1" data-bytes="98 C1">˜Á</span> <span data-cp="73E2" data-bytes="97 5C">—\</span> <span data-cp="73E6" data-bytes="97 73">—s</span> <span data-cp="73F3" data-bytes="97 64">—d</span> <span data-cp="73F9" data-bytes="96 4E">–N</span> <span data-cp="73FB" data-bytes="97 65">—e</span> <span data-cp="7402" data-bytes="8C 5A">ŒZ</span> <span data-cp="7411" data-bytes="89 A1">‰¡</span> <span data-cp="7412" data-bytes="95 FA">•ú</span> <span data-cp="7414" data-bytes="92 D4">’Ô</span> <span data-cp="7419" data-bytes="98 C8">˜È</span> <span data-cp="741C" data-bytes="90 EF">�ï</span> <span data-cp="741E" data-bytes="98 C9">˜É</span> <span data-cp="741F" data-bytes="98 CA">˜Ê</span> <span data-cp="7437" data-bytes="94 6D">”m</span> <span data-cp="7438" data-bytes="94 B7">”·</span> <span data-cp="743C" data-bytes="94 6B">”k</span> <span data-cp="7443" data-bytes="92 FC">’ü</span> <span data-cp="7445" data-bytes="95 EB">•ë</span> <span data-cp="7448" data-bytes="97 6E">—n</span> <span data-cp="744C" data-bytes="87 B8">‡¸</span> <span data-cp="7456" data-bytes="92 D5">’Õ</span> <span data-cp="7461" data-bytes="87 78">‡x</span> <span data-cp="7468" data-bytes="94 7A">”z</span> <span data-cp="746B" data-bytes="95 FB">•û</span> <span data-cp="7479" data-bytes="92 D1">’Ñ</span> <span data-cp="747A" data-bytes="94 5D">”]</span> <span data-cp="748C" data-bytes="93 44">“D</span> <span data-cp="748D" data-bytes="8E A6">Ž¦</span> <span data-cp="7499" data-bytes="92 D3">’Ó</span> <span data-cp="749B" data-bytes="94 B8">”¸</span> <span data-cp="749D" data-bytes="87 79">‡y</span> <span data-cp="74B4" data-bytes="97 5E">—^</span> <span data-cp="74B9" data-bytes="8C AD">Œ­</span> <span data-cp="74C6" data-bytes="87 C1">‡Á</span> <span data-cp="74CC" data-bytes="94 6A">”j</span> <span data-cp="74D0" data-bytes="93 E3">“ã</span> <span data-cp="74D3" data-bytes="98 CF">˜Ï</span> <span data-cp="74E7" data-bytes="A0 D9"> Ù</span> <span data-cp="74F0" data-bytes="A0 BF"> ¿</span> <span data-cp="74F1" data-bytes="A0 4D"> M</span> <span data-cp="74F2" data-bytes="A0 B8"> ¸</span> <span data-cp="74F8" data-bytes="A0 CE"> Î</span> <span data-cp="7505" data-bytes="A0 B7"> ·</span> <span data-cp="7519" data-bytes="89 C3">‰Ã</span> <span data-cp="7534" data-bytes="9D F4">�ô</span> <span data-cp="7535" data-bytes="89 6D">‰m</span> <span data-cp="753B" data-bytes="9C 7B">œ{</span> <span data-cp="7542" data-bytes="98 D2">˜Ò</span> <span data-cp="7546" data-bytes="9F A9">Ÿ©</span> <span data-cp="7551" data-bytes="97 D9">—Ù</span> <span data-cp="7553" data-bytes="A0 C4"> Ä</span> <span data-cp="7555" data-bytes="94 76">”v</span> <span data-cp="7560" data-bytes="99 78">™x</span> <span data-cp="756D" data-bytes="98 D3">˜Ó</span> <span data-cp="7572" data-bytes="98 D4">˜Ô</span> <span data-cp="757A" data-bytes="9F B9">Ÿ¹</span> <span data-cp="7583" data-bytes="94 71">”q</span> <span data-cp="758D" data-bytes="98 D5">˜Õ</span> <span data-cp="75B1" data-bytes="9E 5C">ž\</span> <span data-cp="75C3" data-bytes="A0 44"> D</span> <span data-cp="75C8" data-bytes="98 D7">˜×</span> <span data-cp="75DC" data-bytes="98 D8">˜Ø</span> <span data-cp="75F9" data-bytes="9E EF">žï</span> <span data-cp="7607" data-bytes="9F FE">Ÿþ</span> <span data-cp="763B" data-bytes="9D DD">�Ý</span> <span data-cp="7640" data-bytes="9E E1">žá</span> <span data-cp="764D" data-bytes="98 DA">˜Ú</span> <span data-cp="764E" data-bytes="9D DF">�ß</span> <span data-cp="7654" data-bytes="9E EB">žë</span> <span data-cp="7666" data-bytes="9E 59">žY</span> <span data-cp="7667" data-bytes="A0 5C"> \</span> <span data-cp="7673" data-bytes="94 77">”w</span> <span data-cp="7674" data-bytes="98 DC">˜Ü</span> <span data-cp="767A" data-bytes="98 DE">˜Þ</span> <span data-cp="76D6" data-bytes="9F C2">ŸÂ</span> <span data-cp="76D9" data-bytes="8C 6B">Œk</span> <span data-cp="770C" data-bytes="98 C4">˜Ä</span> <span data-cp="770E" data-bytes="94 B0">”°</span> <span data-cp="770F" data-bytes="94 B1">”±</span> <span data-cp="7724" data-bytes="A0 C1"> Á</span> <span data-cp="772B" data-bytes="A0 CD"> Í</span> <span data-cp="7743" data-bytes="98 E5">˜å</span> <span data-cp="7772" data-bytes="91 E4">‘ä</span> <span data-cp="7777" data-bytes="8F C7">�Ç</span> <span data-cp="7778" data-bytes="94 AE">”®</span> <span data-cp="777A" data-bytes="8A 4F">ŠO</span> <span data-cp="777B" data-bytes="94 B2">”²</span> <span data-cp="7793" data-bytes="8F D4">�Ô</span> <span data-cp="7798" data-bytes="98 EA">˜ê</span> <span data-cp="77B9" data-bytes="9D E0">�à</span> <span data-cp="77BE" data-bytes="98 EE">˜î</span> <span data-cp="77C3" data-bytes="95 C4">•Ä</span> <span data-cp="77CB" data-bytes="98 EF">˜ï</span> <span data-cp="77D7" data-bytes="9B 78">›x</span> <span data-cp="77DD" data-bytes="8C 6E">Œn</span> <span data-cp="77FE" data-bytes="A0 AE"> ®</span> <span data-cp="7808" data-bytes="9D 4C">�L</span> <span data-cp="7818" data-bytes="98 F1">˜ñ</span> <span data-cp="781C" data-bytes="98 F3">˜ó</span> <span data-cp="781E" data-bytes="94 C1">”Á</span> <span data-cp="7839" data-bytes="98 F5">˜õ</span> <span data-cp="783D" data-bytes="96 E2">–â</span> <span data-cp="7842" data-bytes="94 50">”P</span> <span data-cp="7844" data-bytes="96 A2">–¢</span> <span data-cp="7847" data-bytes="98 F6">˜ö</span> <span data-cp="784B" data-bytes="96 E5">–å</span> <span data-cp="7851" data-bytes="98 F7">˜÷</span> <span data-cp="7853" data-bytes="A0 46"> F</span> <span data-cp="7854" data-bytes="96 E3">–ã</span> <span data-cp="7866" data-bytes="98 F8">˜ø</span> <span data-cp="787A" data-bytes="9E E4">žä</span> <span data-cp="7888" data-bytes="94 C3">”Ã</span> <span data-cp="788D" data-bytes="94 C2">”Â</span> <span data-cp="78B6" data-bytes="96 E4">–ä</span> <span data-cp="78B8" data-bytes="89 AC">‰¬</span> <span data-cp="78B9" data-bytes="96 DB">–Û</span> <span data-cp="78D2" data-bytes="94 C4">”Ä</span> <span data-cp="78D8" data-bytes="9F FB">Ÿû</span> <span data-cp="78E4" data-bytes="8C 59">ŒY</span> <span data-cp="78EE" data-bytes="93 C9">“É</span> <span data-cp="78F0" data-bytes="94 E8">”è</span> <span data-cp="78F5" data-bytes="90 C5">�Å</span> <span data-cp="7906" data-bytes="A0 A8"> ¨</span> <span data-cp="7932" data-bytes="98 FD">˜ý</span> <span data-cp="7933" data-bytes="98 FB">˜û</span> <span data-cp="7936" data-bytes="8E BF">Ž¿</span> <span data-cp="793B" data-bytes="8B D8">‹Ø</span> <span data-cp="7958" data-bytes="8F 68">�h</span> <span data-cp="7959" data-bytes="94 C6">”Æ</span> <span data-cp="7962" data-bytes="9D EA">�ê</span> <span data-cp="797E" data-bytes="9C DA">œÚ</span> <span data-cp="7983" data-bytes="9C 72">œr</span> <span data-cp="7987" data-bytes="89 C9">‰É</span> <span data-cp="7991" data-bytes="99 41">™A</span> <span data-cp="7999" data-bytes="99 42">™B</span> <span data-cp="799B" data-bytes="94 CA">”Ê</span> <span data-cp="799F" data-bytes="91 D7">‘×</span> <span data-cp="79A5" data-bytes="94 CC">”Ì</span> <span data-cp="79C4" data-bytes="97 A8">—¨</span> <span data-cp="79CA" data-bytes="8C DE">ŒÞ</span> <span data-cp="79D0" data-bytes="87 B3">‡³</span> <span data-cp="79E2" data-bytes="96 D1">–Ñ</span> <span data-cp="79E3" data-bytes="9C BD">œ½</span> <span data-cp="79F1" data-bytes="94 D5">”Õ</span> <span data-cp="79F4" data-bytes="94 D0">”Ð</span> <span data-cp="7A06" data-bytes="99 44">™D</span> <span data-cp="7A2A" data-bytes="8C 63">Œc</span> <span data-cp="7A2C" data-bytes="87 BB">‡»</span> <span data-cp="7A2D" data-bytes="A0 B3"> ³</span> <span data-cp="7A32" data-bytes="87 B4">‡´</span> <span data-cp="7A3A" data-bytes="94 CF">”Ï</span> <span data-cp="7A3E" data-bytes="9F FA">Ÿú</span> <span data-cp="7A43" data-bytes="91 E5">‘å</span> <span data-cp="7A45" data-bytes="9C 6A">œj</span> <span data-cp="7A49" data-bytes="8E 49">ŽI</span> <span data-cp="7A65" data-bytes="8E 4C">ŽL</span> <span data-cp="7A72" data-bytes="87 C9">‡É</span> <span data-cp="7A7D" data-bytes="8E 4D">ŽM</span> <span data-cp="7A83" data-bytes="9A 73">šs</span> <span data-cp="7A91" data-bytes="99 47">™G</span> <span data-cp="7A93" data-bytes="8C B1">Œ±</span> <span data-cp="7AB0" data-bytes="8E 50">ŽP</span> <span data-cp="7ABB" data-bytes="8E 4F">ŽO</span> <span data-cp="7ABC" data-bytes="99 49">™I</span> <span data-cp="7AC2" data-bytes="8E 51">ŽQ</span> <span data-cp="7AC3" data-bytes="8E 52">ŽR</span> <span data-cp="7AC8" data-bytes="9A B2">š²</span> <span data-cp="7AC9" data-bytes="89 A5">‰¥</span> <span data-cp="7ACF" data-bytes="99 4C">™L</span> <span data-cp="7AD3" data-bytes="9F F8">Ÿø</span> <span data-cp="7ADA" data-bytes="8E 56">ŽV</span> <span data-cp="7ADB" data-bytes="99 4D">™M</span> <span data-cp="7ADC" data-bytes="91 CA">‘Ê</span> <span data-cp="7ADD" data-bytes="8E 57">ŽW</span> <span data-cp="7AE2" data-bytes="94 E1">”á</span> <span data-cp="7AE7" data-bytes="90 47">�G</span> <span data-cp="7AE9" data-bytes="8F D8">�Ø</span> <span data-cp="7AEA" data-bytes="8E 58">ŽX</span> <span data-cp="7AFC" data-bytes="87 A3">‡£</span> <span data-cp="7AFE" data-bytes="94 EB">”ë</span> <span data-cp="7B0B" data-bytes="8E 5C">Ž\</span> <span data-cp="7B0C" data-bytes="95 53">•S</span> <span data-cp="7B14" data-bytes="9F E5">Ÿå</span> <span data-cp="7B1F" data-bytes="9F 56">ŸV</span> <span data-cp="7B27" data-bytes="95 4F">•O</span> <span data-cp="7B29" data-bytes="8E 5E">Ž^</span> <span data-cp="7B39" data-bytes="99 6A">™j</span> <span data-cp="7B42" data-bytes="9C 64">œd</span> <span data-cp="7B43" data-bytes="9C D9">œÙ</span> <span data-cp="7B51" data-bytes="9D 5A">�Z</span> <span data-cp="7B55" data-bytes="8E 5D">Ž]</span> <span data-cp="7B62" data-bytes="99 50">™P</span> <span data-cp="7B6C" data-bytes="99 51">™Q</span> <span data-cp="7B6F" data-bytes="8E 62">Žb</span> <span data-cp="7B7B" data-bytes="99 52">™R</span> <span data-cp="7B92" data-bytes="8E 68">Žh</span> <span data-cp="7BA2" data-bytes="8E 61">Ža</span> <span data-cp="7BA3" data-bytes="9F 59">ŸY</span> <span data-cp="7BAE" data-bytes="87 D0">‡Ð</span> <span data-cp="7BB2" data-bytes="8B B3">‹³</span> <span data-cp="7BB8" data-bytes="8E 69">Ži</span> <span data-cp="7BC5" data-bytes="87 B9">‡¹</span> <span data-cp="7BCF" data-bytes="9F 5D">Ÿ]</span> <span data-cp="7BD0" data-bytes="8E 66">Žf</span> <span data-cp="7BEC" data-bytes="8C B2">Œ²</span> <span data-cp="7BFA" data-bytes="8E 6E">Žn</span> <span data-cp="7BFC" data-bytes="9F 64">Ÿd</span> <span data-cp="7C06" data-bytes="8E 6F">Žo</span> <span data-cp="7C12" data-bytes="99 53">™S</span> <span data-cp="7C1B" data-bytes="99 54">™T</span> <span data-cp="7C35" data-bytes="8E 70">Žp</span> <span data-cp="7C42" data-bytes="9F 61">Ÿa</span> <span data-cp="7C44" data-bytes="8E 72">Žr</span> <span data-cp="7C51" data-bytes="A0 6B"> k</span> <span data-cp="7C56" data-bytes="9F 40">Ÿ@</span> <span data-cp="7C5D" data-bytes="94 ED">”í</span> <span data-cp="7C6D" data-bytes="94 EE">”î</span> <span data-cp="7C70" data-bytes="9F BD">Ÿ½</span> <span data-cp="7C74" data-bytes="8E 7B">Ž{</span> <span data-cp="7C7B" data-bytes="99 57">™W</span> <span data-cp="7C7C" data-bytes="94 F7">”÷</span> <span data-cp="7C7E" data-bytes="9F 5F">Ÿ_</span> <span data-cp="7C83" data-bytes="8E 73">Žs</span> <span data-cp="7C86" data-bytes="9F 62">Ÿb</span> <span data-cp="7C8E" data-bytes="94 F6">”ö</span> <span data-cp="7C9C" data-bytes="99 58">™X</span> <span data-cp="7CA6" data-bytes="8E 75">Žu</span> <span data-cp="7CAC" data-bytes="90 72">�r</span> <span data-cp="7CAE" data-bytes="94 F8">”ø</span> <span data-cp="7CB8" data-bytes="99 5A">™Z</span> <span data-cp="7CC2" data-bytes="A0 B0"> °</span> <span data-cp="7CC3" data-bytes="8C B3">Œ³</span> <span data-cp="7CC7" data-bytes="8E 79">Žy</span> <span data-cp="7CC9" data-bytes="8E 78">Žx</span> <span data-cp="7CCD" data-bytes="94 F3">”ó</span> <span data-cp="7CCE" data-bytes="8E 7E">Ž~</span> <span data-cp="7CD3" data-bytes="98 AF">˜¯</span> <span data-cp="7CDA" data-bytes="A0 B2"> ²</span> <span data-cp="7CE6" data-bytes="8E 7A">Žz</span> <span data-cp="7CED" data-bytes="99 5C">™\</span> <span data-cp="7CF3" data-bytes="8E 7C">Ž|</span> <span data-cp="7CF5" data-bytes="8E 7D">Ž}</span> <span data-cp="7CF9" data-bytes="8B D9">‹Ù</span> <span data-cp="7CFC" data-bytes="89 A2">‰¢</span> <span data-cp="7D25" data-bytes="9E D7">ž×</span> <span data-cp="7D4D" data-bytes="A0 B6"> ¶</span> <span data-cp="7D5A" data-bytes="9E 42">žB</span> <span data-cp="7D5D" data-bytes="8E A4">Ž¤</span> <span data-cp="7D89" data-bytes="8E A7">Ž§</span> <span data-cp="7D8B" data-bytes="8C 76">Œv</span> <span data-cp="7D95" data-bytes="87 67">‡g</span> <span data-cp="7D97" data-bytes="95 42">•B</span> <span data-cp="7DA4" data-bytes="98 7D">˜}</span> <span data-cp="7DA8" data-bytes="97 55">—U</span> <span data-cp="7DAB" data-bytes="8E A8">Ž¨</span> <span data-cp="7DB3" data-bytes="8E AA">Žª</span> <span data-cp="7DCD" data-bytes="89 A3">‰£</span> <span data-cp="7DCF" data-bytes="99 60">™`</span> <span data-cp="7DD0" data-bytes="99 62">™b</span> <span data-cp="7DD2" data-bytes="8E AB">Ž«</span> <span data-cp="7DD3" data-bytes="94 FC">”ü</span> <span data-cp="7DD4" data-bytes="99 61">™a</span> <span data-cp="7DDC" data-bytes="94 FA">”ú</span> <span data-cp="7DE4" data-bytes="8E AE">Ž®</span> <span data-cp="7DE5" data-bytes="8E B2">Ž²</span> <span data-cp="7DF5" data-bytes="8E B0">Ž°</span> <span data-cp="7DFD" data-bytes="99 63">™c</span> <span data-cp="7DFE" data-bytes="97 AA">—ª</span> <span data-cp="7E07" data-bytes="94 FB">”û</span> <span data-cp="7E1D" data-bytes="8E B4">Ž´</span> <span data-cp="7E27" data-bytes="8E BB">Ž»</span> <span data-cp="7E5B" data-bytes="8C DC">ŒÜ</span> <span data-cp="7E65" data-bytes="98 76">˜v</span> <span data-cp="7E67" data-bytes="8E A1">Ž¡</span> <span data-cp="7E6C" data-bytes="8C B4">Œ´</span> <span data-cp="7E6E" data-bytes="8E B7">Ž·</span> <span data-cp="7E7F" data-bytes="9D A6">�¦</span> <span data-cp="7E87" data-bytes="9B 7B">›{</span> <span data-cp="7E8E" data-bytes="9E B0">ž°</span> <span data-cp="7E92" data-bytes="8E B8">Ž¸</span> <span data-cp="7E9F" data-bytes="9D 70">�p</span> <span data-cp="7EA4" data-bytes="89 6E">‰n</span> <span data-cp="7EAC" data-bytes="89 6F">‰o</span> <span data-cp="7EBA" data-bytes="89 70">‰p</span> <span data-cp="7EC7" data-bytes="89 71">‰q</span> <span data-cp="7ECF" data-bytes="89 72">‰r</span> <span data-cp="7EDF" data-bytes="89 73">‰s</span> <span data-cp="7F06" data-bytes="89 74">‰t</span> <span data-cp="7F37" data-bytes="89 75">‰u</span> <span data-cp="7F40" data-bytes="8E BC">Ž¼</span> <span data-cp="7F41" data-bytes="8E BD">Ž½</span> <span data-cp="7F47" data-bytes="8E BE">Ž¾</span> <span data-cp="7F49" data-bytes="9D D1">�Ñ</span> <span data-cp="7F4E" data-bytes="94 FD">”ý</span> <span data-cp="7F52" data-bytes="8B D7">‹×</span> <span data-cp="7F53" data-bytes="8B DA">‹Ú</span> <span data-cp="7F71" data-bytes="A0 E2"> â</span> <span data-cp="7F78" data-bytes="9F E9">Ÿé</span> <span data-cp="7F93" data-bytes="8A E7">Šç</span> <span data-cp="7F97" data-bytes="8E C2">ŽÂ</span> <span data-cp="7FA3" data-bytes="8E C4">ŽÄ</span> <span data-cp="7FAE" data-bytes="99 64">™d</span> <span data-cp="7FB4" data-bytes="99 65">™e</span> <span data-cp="7FDD" data-bytes="95 4E">•N</span> <span data-cp="7FE7" data-bytes="98 B3">˜³</span> <span data-cp="7FFA" data-bytes="8E CB">ŽË</span> <span data-cp="8002" data-bytes="8B DF">‹ß</span> <span data-cp="8005" data-bytes="8E CD">ŽÍ</span> <span data-cp="8008" data-bytes="8E CE">ŽÎ</span> <span data-cp="801D" data-bytes="8E CF">ŽÏ</span> <span data-cp="8020" data-bytes="99 68">™h</span> <span data-cp="8025" data-bytes="99 69">™i</span> <span data-cp="8028" data-bytes="8E D0">ŽÐ</span> <span data-cp="802E" data-bytes="99 6B">™k</span> <span data-cp="802F" data-bytes="8E D1">ŽÑ</span> <span data-cp="8031" data-bytes="99 6C">™l</span> <span data-cp="803B" data-bytes="8E D4">ŽÔ</span> <span data-cp="803C" data-bytes="8E D5">ŽÕ</span> <span data-cp="8054" data-bytes="99 6D">™m</span> <span data-cp="805B" data-bytes="A0 BE"> ¾</span> <span data-cp="8061" data-bytes="8E D6">ŽÖ</span> <span data-cp="8062" data-bytes="A0 BC"> ¼</span> <span data-cp="8063" data-bytes="A0 B5"> µ</span> <span data-cp="8066" data-bytes="A0 B4"> ´</span> <span data-cp="8080" data-bytes="8B E0">‹à</span> <span data-cp="809F" data-bytes="89 B5">‰µ</span> <span data-cp="80A7" data-bytes="8E DD">ŽÝ</span> <span data-cp="80B6" data-bytes="9E 5D">ž]</span> <span data-cp="80B7" data-bytes="99 71">™q</span> <span data-cp="80BC" data-bytes="89 AE">‰®</span> <span data-cp="80BD" data-bytes="9D E8">�è</span> <span data-cp="80C6" data-bytes="95 65">•e</span> <span data-cp="80E9" data-bytes="99 72">™r</span> <span data-cp="80EC" data-bytes="8B 5C">‹\</span> <span data-cp="80F6" data-bytes="89 B1">‰±</span> <span data-cp="8103" data-bytes="A0 C0"> À</span> <span data-cp="8107" data-bytes="8E DF">Žß</span> <span data-cp="8109" data-bytes="95 66">•f</span> <span data-cp="810C" data-bytes="99 74">™t</span> <span data-cp="810E" data-bytes="99 76">™v</span> <span data-cp="8112" data-bytes="99 77">™w</span> <span data-cp="8114" data-bytes="99 79">™y</span> <span data-cp="8117" data-bytes="9D DA">�Ú</span> <span data-cp="811A" data-bytes="8E E0">Žà</span> <span data-cp="812A" data-bytes="93 5C">“\</span> <span data-cp="8132" data-bytes="9D E6">�æ</span> <span data-cp="8134" data-bytes="8B 5F">‹_</span> <span data-cp="8137" data-bytes="95 63">•c</span> <span data-cp="8142" data-bytes="95 67">•g</span> <span data-cp="8148" data-bytes="9D E3">�ã</span> <span data-cp="8156" data-bytes="99 7C">™|</span> <span data-cp="8159" data-bytes="99 7D">™}</span> <span data-cp="815A" data-bytes="99 7E">™~</span> <span data-cp="816C" data-bytes="8C FB">Œû</span> <span data-cp="816D" data-bytes="8B 5B">‹[</span> <span data-cp="817C" data-bytes="99 A3">™£</span> <span data-cp="8184" data-bytes="99 A4">™¤</span> <span data-cp="8193" data-bytes="99 A6">™¦</span> <span data-cp="81A5" data-bytes="99 A8">™¨</span> <span data-cp="81AA" data-bytes="8A BE">Š¾</span> <span data-cp="81B6" data-bytes="9E 61">ža</span> <span data-cp="81C1" data-bytes="99 AA">™ª</span> <span data-cp="81C8" data-bytes="A0 C8"> È</span> <span data-cp="81E4" data-bytes="99 AB">™«</span> <span data-cp="81F6" data-bytes="98 C2">˜Â</span> <span data-cp="8218" data-bytes="8E E8">Žè</span> <span data-cp="821A" data-bytes="A0 BA"> º</span> <span data-cp="8229" data-bytes="8E EE">Žî</span> <span data-cp="822D" data-bytes="9E BF">ž¿</span> <span data-cp="823E" data-bytes="89 C2">‰Â</span> <span data-cp="8254" data-bytes="99 AC">™¬</span> <span data-cp="8262" data-bytes="95 6B">•k</span> <span data-cp="8265" data-bytes="95 6C">•l</span> <span data-cp="8276" data-bytes="99 AF">™¯</span> <span data-cp="8279" data-bytes="99 4A">™J</span> <span data-cp="827A" data-bytes="89 76">‰v</span> <span data-cp="827B" data-bytes="8F 48">�H</span> <span data-cp="82A6" data-bytes="99 AE">™®</span> <span data-cp="82AA" data-bytes="8E FB">Žû</span> <span data-cp="82BF" data-bytes="8C D0">ŒÐ</span> <span data-cp="82C4" data-bytes="8B 52">‹R</span> <span data-cp="82CA" data-bytes="99 B0">™°</span> <span data-cp="82CF" data-bytes="89 77">‰w</span> <span data-cp="82D0" data-bytes="8F 41">�A</span> <span data-cp="82D8" data-bytes="99 B1">™±</span> <span data-cp="82E2" data-bytes="8F 49">�I</span> <span data-cp="82F7" data-bytes="9D E4">�ä</span> <span data-cp="82F8" data-bytes="8C B5">Œµ</span> <span data-cp="82FD" data-bytes="9B 54">›T</span> <span data-cp="82FF" data-bytes="99 B2">™²</span> <span data-cp="830B" data-bytes="9E 68">žh</span> <span data-cp="8318" data-bytes="8F 4A">�J</span> <span data-cp="831A" data-bytes="8F 42">�B</span> <span data-cp="831D" data-bytes="8F 51">�Q</span> <span data-cp="833D" data-bytes="98 46">˜F</span> <span data-cp="8357" data-bytes="99 B4">™´</span> <span data-cp="8362" data-bytes="8E F5">Žõ</span> <span data-cp="8366" data-bytes="9C CD">œÍ</span> <span data-cp="836F" data-bytes="89 78">‰x</span> <span data-cp="8385" data-bytes="8F 53">�S</span> <span data-cp="8391" data-bytes="8F 6F">�o</span> <span data-cp="839C" data-bytes="8E 63">Žc</span> <span data-cp="83AC" data-bytes="8F 56">�V</span> <span data-cp="83BE" data-bytes="9F C6">ŸÆ</span> <span data-cp="83C1" data-bytes="8F 57">�W</span> <span data-cp="83CF" data-bytes="9C 77">œw</span> <span data-cp="83D3" data-bytes="8F 58">�X</span> <span data-cp="83ED" data-bytes="98 48">˜H</span> <span data-cp="8405" data-bytes="99 B7">™·</span> <span data-cp="840F" data-bytes="8F 6E">�n</span> <span data-cp="8414" data-bytes="96 65">–e</span> <span data-cp="8418" data-bytes="9D E7">�ç</span> <span data-cp="841C" data-bytes="9E 62">žb</span> <span data-cp="8420" data-bytes="96 CC">–Ì</span> <span data-cp="8421" data-bytes="8E 67">Žg</span> <span data-cp="8426" data-bytes="98 7E">˜~</span> <span data-cp="843E" data-bytes="97 FC">—ü</span> <span data-cp="8448" data-bytes="98 F9">˜ù</span> <span data-cp="844A" data-bytes="8F 66">�f</span> <span data-cp="8453" data-bytes="95 6E">•n</span> <span data-cp="8455" data-bytes="92 45">’E</span> <span data-cp="8458" data-bytes="8F 60">�`</span> <span data-cp="845C" data-bytes="9E D1">žÑ</span> <span data-cp="8464" data-bytes="99 B9">™¹</span> <span data-cp="8471" data-bytes="8F 62">�b</span> <span data-cp="8472" data-bytes="97 4C">—L</span> <span data-cp="847F" data-bytes="91 C7">‘Ç</span> <span data-cp="8480" data-bytes="95 5F">•_</span> <span data-cp="8484" data-bytes="87 AB">‡«</span> <span data-cp="8488" data-bytes="99 BB">™»</span> <span data-cp="8492" data-bytes="8E 6D">Žm</span> <span data-cp="8493" data-bytes="8F 71">�q</span> <span data-cp="8496" data-bytes="94 CB">”Ë</span> <span data-cp="84A3" data-bytes="95 B1">•±</span> <span data-cp="84A8" data-bytes="8F 69">�i</span> <span data-cp="84AD" data-bytes="9A F2">šò</span> <span data-cp="84BD" data-bytes="96 C3">–Ã</span> <span data-cp="84BE" data-bytes="99 BD">™½</span> <span data-cp="84DA" data-bytes="A0 CF"> Ï</span> <span data-cp="84DE" data-bytes="8F 6D">�m</span> <span data-cp="84E1" data-bytes="99 BE">™¾</span> <span data-cp="84E2" data-bytes="8E F4">Žô</span> <span data-cp="84E4" data-bytes="8F 72">�r</span> <span data-cp="84E5" data-bytes="95 E4">•ä</span> <span data-cp="84F8" data-bytes="99 BF">™¿</span> <span data-cp="8503" data-bytes="92 42">’B</span> <span data-cp="8504" data-bytes="87 D7">‡×</span> <span data-cp="8510" data-bytes="99 C0">™À</span> <span data-cp="8534" data-bytes="8F 77">�w</span> <span data-cp="8538" data-bytes="99 C1">™Á</span> <span data-cp="854B" data-bytes="8F 40">�@</span> <span data-cp="8552" data-bytes="99 C2">™Â</span> <span data-cp="855A" data-bytes="8F 5C">�\</span> <span data-cp="855F" data-bytes="8C BD">Œ½</span> <span data-cp="856F" data-bytes="99 C4">™Ä</span> <span data-cp="8570" data-bytes="99 C5">™Å</span> <span data-cp="8573" data-bytes="8F 7B">�{</span> <span data-cp="8593" data-bytes="87 76">‡v</span> <span data-cp="8597" data-bytes="8C B6">Œ¶</span> <span data-cp="85C1" data-bytes="8F A3">�£</span> <span data-cp="85D6" data-bytes="8C CE">ŒÎ</span> <span data-cp="85E0" data-bytes="99 C6">™Æ</span> <span data-cp="85EE" data-bytes="96 CD">–Í</span> <span data-cp="85FC" data-bytes="96 C7">–Ç</span> <span data-cp="8602" data-bytes="8F A5">�¥</span> <span data-cp="860F" data-bytes="8C 61">Œa</span> <span data-cp="8610" data-bytes="95 70">•p</span> <span data-cp="8613" data-bytes="87 AF">‡¯</span> <span data-cp="8614" data-bytes="93 68">“h</span> <span data-cp="8616" data-bytes="8F 7E">�~</span> <span data-cp="8628" data-bytes="8F AA">�ª</span> <span data-cp="862F" data-bytes="A0 50"> P</span> <span data-cp="8642" data-bytes="90 D3">�Ó</span> <span data-cp="8645" data-bytes="95 56">•V</span> <span data-cp="866C" data-bytes="8F B8">�¸</span> <span data-cp="8672" data-bytes="99 C8">™È</span> <span data-cp="867E" data-bytes="8F AF">�¯</span> <span data-cp="8692" data-bytes="99 C9">™É</span> <span data-cp="86A0" data-bytes="95 79">•y</span> <span data-cp="86AD" data-bytes="9F 49">ŸI</span> <span data-cp="86B2" data-bytes="99 CA">™Ê</span> <span data-cp="86EF" data-bytes="99 CB">™Ë</span> <span data-cp="8770" data-bytes="9D D5">�Õ</span> <span data-cp="8771" data-bytes="8F B0">�°</span> <span data-cp="8786" data-bytes="9E 5F">ž_</span> <span data-cp="878B" data-bytes="99 CD">™Í</span> <span data-cp="878C" data-bytes="A0 C9"> É</span> <span data-cp="87A5" data-bytes="9A DB">šÛ</span> <span data-cp="87A9" data-bytes="A0 C6"> Æ</span> <span data-cp="87B1" data-bytes="8F B4">�´</span> <span data-cp="87C1" data-bytes="A0 D7"> ×</span> <span data-cp="87CE" data-bytes="A0 C7"> Ç</span> <span data-cp="87D6" data-bytes="A0 43"> C</span> <span data-cp="87DA" data-bytes="8F B5">�µ</span> <span data-cp="87EE" data-bytes="8F B2">�²</span> <span data-cp="87F5" data-bytes="A0 61"> a</span> <span data-cp="8804" data-bytes="9E 5E">ž^</span> <span data-cp="880F" data-bytes="8F B6">�¶</span> <span data-cp="8818" data-bytes="9F E8">Ÿè</span> <span data-cp="8827" data-bytes="9C B2">œ²</span> <span data-cp="882D" data-bytes="95 7C">•|</span> <span data-cp="8842" data-bytes="9F C7">ŸÇ</span> <span data-cp="8845" data-bytes="8F BB">�»</span> <span data-cp="8846" data-bytes="8F BC">�¼</span> <span data-cp="884F" data-bytes="8F EC">�ì</span> <span data-cp="885E" data-bytes="8F C0">�À</span> <span data-cp="8860" data-bytes="93 6A">“j</span> <span data-cp="8864" data-bytes="8B E4">‹ä</span> <span data-cp="8865" data-bytes="9C 7C">œ|</span> <span data-cp="886E" data-bytes="95 A1">•¡</span> <span data-cp="8887" data-bytes="95 A3">•£</span> <span data-cp="888F" data-bytes="8C 45">ŒE</span> <span data-cp="8890" data-bytes="8C B8">Œ¸</span> <span data-cp="889C" data-bytes="8F C1">�Á</span> <span data-cp="889D" data-bytes="87 B7">‡·</span> <span data-cp="88A0" data-bytes="A0 52"> R</span> <span data-cp="88AE" data-bytes="99 D0">™Ð</span> <span data-cp="88B4" data-bytes="8F C3">�Ã</span> <span data-cp="88B5" data-bytes="8F C4">�Ä</span> <span data-cp="88BF" data-bytes="95 A4">•¤</span> <span data-cp="88C5" data-bytes="8F C6">�Æ</span> <span data-cp="88C7" data-bytes="9E 60">ž`</span> <span data-cp="88E6" data-bytes="95 A5">•¥</span> <span data-cp="88F5" data-bytes="9C B3">œ³</span> <span data-cp="88FF" data-bytes="99 D1">™Ñ</span> <span data-cp="8924" data-bytes="99 D2">™Ò</span> <span data-cp="8943" data-bytes="9C C2">œÂ</span> <span data-cp="8947" data-bytes="99 D3">™Ó</span> <span data-cp="894D" data-bytes="95 A7">•§</span> <span data-cp="8954" data-bytes="95 A9">•©</span> <span data-cp="8965" data-bytes="95 A6">•¦</span> <span data-cp="8977" data-bytes="9C 5D">œ]</span> <span data-cp="8980" data-bytes="98 E2">˜â</span> <span data-cp="8987" data-bytes="8F C9">�É</span> <span data-cp="8989" data-bytes="A0 C2"> Â</span> <span data-cp="898A" data-bytes="8F CA">�Ê</span> <span data-cp="8991" data-bytes="99 D4">™Ô</span> <span data-cp="8994" data-bytes="A0 B9"> ¹</span> <span data-cp="89A5" data-bytes="9B 58">›X</span> <span data-cp="89A6" data-bytes="8F CB">�Ë</span> <span data-cp="89A7" data-bytes="8F CD">�Í</span> <span data-cp="89A9" data-bytes="8F CC">�Ì</span> <span data-cp="89BC" data-bytes="8F CE">�Î</span> <span data-cp="89C1" data-bytes="8B E5">‹å</span> <span data-cp="89C6" data-bytes="89 79">‰y</span> <span data-cp="89E7" data-bytes="8F D0">�Ð</span> <span data-cp="8A1C" data-bytes="95 B6">•¶</span> <span data-cp="8A29" data-bytes="99 D6">™Ö</span> <span data-cp="8A2B" data-bytes="95 E5">•å</span> <span data-cp="8A38" data-bytes="99 D7">™×</span> <span data-cp="8A3D" data-bytes="95 B5">•µ</span> <span data-cp="8A49" data-bytes="A0 CA"> Ê</span> <span data-cp="8A67" data-bytes="9F FD">Ÿý</span> <span data-cp="8A7E" data-bytes="A0 58"> X</span> <span data-cp="8A90" data-bytes="8F D6">�Ö</span> <span data-cp="8A94" data-bytes="99 D8">™Ø</span> <span data-cp="8A9C" data-bytes="8F D3">�Ó</span> <span data-cp="8AA9" data-bytes="8F E5">�å</span> <span data-cp="8AAF" data-bytes="8F E9">�é</span> <span data-cp="8AB4" data-bytes="99 D9">™Ù</span> <span data-cp="8ACC" data-bytes="8C F7">Œ÷</span> <span data-cp="8ADA" data-bytes="92 7C">’|</span> <span data-cp="8AEA" data-bytes="9C 45">œE</span> <span data-cp="8AF9" data-bytes="8C E8">Œè</span> <span data-cp="8B0C" data-bytes="8F DE">�Þ</span> <span data-cp="8B1F" data-bytes="8F DF">�ß</span> <span data-cp="8B2D" data-bytes="A0 4B"> K</span> <span data-cp="8B3F" data-bytes="8F E2">�â</span> <span data-cp="8B43" data-bytes="A0 CC"> Ì</span> <span data-cp="8B4C" data-bytes="8F E3">�ã</span> <span data-cp="8B4D" data-bytes="8F E4">�ä</span> <span data-cp="8B5E" data-bytes="9B C4">›Ä</span> <span data-cp="8B62" data-bytes="9B FC">›ü</span> <span data-cp="8B69" data-bytes="96 4C">–L</span> <span data-cp="8B81" data-bytes="9A F6">šö</span> <span data-cp="8B83" data-bytes="8C AE">Œ®</span> <span data-cp="8B8F" data-bytes="87 CB">‡Ë</span> <span data-cp="8B90" data-bytes="8F E7">�ç</span> <span data-cp="8B9B" data-bytes="8F E8">�è</span> <span data-cp="8BA0" data-bytes="8B E7">‹ç</span> <span data-cp="8BBE" data-bytes="89 7A">‰z</span> <span data-cp="8BE2" data-bytes="89 7B">‰{</span> <span data-cp="8C51" data-bytes="99 DA">™Ú</span> <span data-cp="8C9B" data-bytes="8F ED">�í</span> <span data-cp="8C9F" data-bytes="95 C0">•À</span> <span data-cp="8CAD" data-bytes="A0 CB"> Ë</span> <span data-cp="8CCD" data-bytes="9E 48">žH</span> <span data-cp="8CD4" data-bytes="99 DB">™Û</span> <span data-cp="8CD6" data-bytes="8F F3">�ó</span> <span data-cp="8CDB" data-bytes="8F F9">�ù</span> <span data-cp="8CE9" data-bytes="95 C1">•Á</span> <span data-cp="8CEB" data-bytes="A0 4E"> N</span> <span data-cp="8CF2" data-bytes="99 DC">™Ü</span> <span data-cp="8CF7" data-bytes="A0 64"> d</span> <span data-cp="8D03" data-bytes="8F F7">�÷</span> <span data-cp="8D0B" data-bytes="89 B0">‰°</span> <span data-cp="8D0C" data-bytes="A0 48"> H</span> <span data-cp="8D11" data-bytes="8F FB">�û</span> <span data-cp="8D12" data-bytes="8F F6">�ö</span> <span data-cp="8D18" data-bytes="9D DC">�Ü</span> <span data-cp="8D1C" data-bytes="99 DD">™Ý</span> <span data-cp="8D1D" data-bytes="8B E8">‹è</span> <span data-cp="8D77" data-bytes="8F FE">�þ</span> <span data-cp="8D7A" data-bytes="92 C1">’Á</span> <span data-cp="8D82" data-bytes="9F D6">ŸÖ</span> <span data-cp="8DA6" data-bytes="A0 D2"> Ò</span> <span data-cp="8DA9" data-bytes="90 40">�@</span> <span data-cp="8DC0" data-bytes="8A C4">ŠÄ</span> <span data-cp="8DC3" data-bytes="99 E0">™à</span> <span data-cp="8DD4" data-bytes="9F F0">Ÿð</span> <span data-cp="8E01" data-bytes="9F F3">Ÿó</span> <span data-cp="8E0E" data-bytes="9D BF">�¿</span> <span data-cp="8E28" data-bytes="9F F6">Ÿö</span> <span data-cp="8E2A" data-bytes="95 C8">•È</span> <span data-cp="8E2D" data-bytes="9E 5A">žZ</span> <span data-cp="8E3A" data-bytes="99 E3">™ã</span> <span data-cp="8E46" data-bytes="8A 4A">ŠJ</span> <span data-cp="8E4F" data-bytes="9F F1">Ÿñ</span> <span data-cp="8E68" data-bytes="8A A7">Š§</span> <span data-cp="8E71" data-bytes="99 E6">™æ</span> <span data-cp="8E75" data-bytes="9F F7">Ÿ÷</span> <span data-cp="8E77" data-bytes="9F ED">Ÿí</span> <span data-cp="8E7E" data-bytes="8A 5C">Š\</span> <span data-cp="8E80" data-bytes="9D AE">�®</span> <span data-cp="8EA7" data-bytes="95 C9">•É</span> <span data-cp="8EAD" data-bytes="90 48">�H</span> <span data-cp="8EB0" data-bytes="99 E8">™è</span> <span data-cp="8EB6" data-bytes="90 49">�I</span> <span data-cp="8EB9" data-bytes="8C BA">Œº</span> <span data-cp="8EBC" data-bytes="90 B1">�±</span> <span data-cp="8EC3" data-bytes="90 4A">�J</span> <span data-cp="8ECE" data-bytes="99 EA">™ê</span> <span data-cp="8EDA" data-bytes="9B D1">›Ñ</span> <span data-cp="8EE2" data-bytes="99 EB">™ë</span> <span data-cp="8EE4" data-bytes="99 EC">™ì</span> <span data-cp="8EED" data-bytes="99 ED">™í</span> <span data-cp="8EF2" data-bytes="99 EE">™î</span> <span data-cp="8F0B" data-bytes="9D 57">�W</span> <span data-cp="8F19" data-bytes="90 4C">�L</span> <span data-cp="8F2D" data-bytes="90 4D">�M</span> <span data-cp="8F30" data-bytes="95 CB">•Ë</span> <span data-cp="8F36" data-bytes="9C 42">œB</span> <span data-cp="8F41" data-bytes="97 E2">—â</span> <span data-cp="8F4A" data-bytes="95 CC">•Ì</span> <span data-cp="8F5C" data-bytes="9F 78">Ÿx</span> <span data-cp="8F66" data-bytes="89 7C">‰|</span> <span data-cp="8F67" data-bytes="89 7D">‰}</span> <span data-cp="8F6E" data-bytes="89 7E">‰~</span> <span data-cp="8F93" data-bytes="99 5D">™]</span> <span data-cp="8FA0" data-bytes="9B 5A">›Z</span> <span data-cp="8FA5" data-bytes="90 50">�P</span> <span data-cp="8FA7" data-bytes="8C 4F">ŒO</span> <span data-cp="8FB3" data-bytes="90 54">�T</span> <span data-cp="8FB6" data-bytes="9A A8">š¨</span> <span data-cp="8FB7" data-bytes="99 EF">™ï</span> <span data-cp="8FB9" data-bytes="9D A3">�£</span> <span data-cp="8FBA" data-bytes="9D A1">�¡</span> <span data-cp="8FBB" data-bytes="99 43">™C</span> <span data-cp="8FBC" data-bytes="99 45">™E</span> <span data-cp="8FBE" data-bytes="9D 7D">�}</span> <span data-cp="8FC1" data-bytes="99 F0">™ð</span> <span data-cp="8FCA" data-bytes="99 F1">™ñ</span> <span data-cp="8FCC" data-bytes="99 F2">™ò</span> <span data-cp="8FCF" data-bytes="8C BC">Œ¼</span> <span data-cp="8FD0" data-bytes="9D 60">�`</span> <span data-cp="8FDA" data-bytes="A0 A3"> £</span> <span data-cp="8FF9" data-bytes="90 5B">�[</span> <span data-cp="9008" data-bytes="9E DB">žÛ</span> <span data-cp="9012" data-bytes="9D 79">�y</span> <span data-cp="9033" data-bytes="99 F3">™ó</span> <span data-cp="9037" data-bytes="90 62">�b</span> <span data-cp="9046" data-bytes="87 BD">‡½</span> <span data-cp="904C" data-bytes="9F 55">ŸU</span> <span data-cp="9056" data-bytes="9B F9">›ù</span> <span data-cp="9061" data-bytes="90 65">�e</span> <span data-cp="9064" data-bytes="96 E0">–à</span> <span data-cp="906C" data-bytes="98 BE">˜¾</span> <span data-cp="9097" data-bytes="95 D9">•Ù</span> <span data-cp="90A8" data-bytes="90 68">�h</span> <span data-cp="90AE" data-bytes="90 6C">�l</span> <span data-cp="90BB" data-bytes="95 D8">•Ø</span> <span data-cp="90C4" data-bytes="90 6A">�j</span> <span data-cp="90FD" data-bytes="90 6D">�m</span> <span data-cp="9104" data-bytes="9C 68">œh</span> <span data-cp="9151" data-bytes="9F B2">Ÿ²</span> <span data-cp="9159" data-bytes="9F AE">Ÿ®</span> <span data-cp="915C" data-bytes="9F B0">Ÿ°</span> <span data-cp="915E" data-bytes="89 AD">‰­</span> <span data-cp="9167" data-bytes="90 6E">�n</span> <span data-cp="9170" data-bytes="9E 71">žq</span> <span data-cp="9176" data-bytes="9E 4A">žJ</span> <span data-cp="917C" data-bytes="9F DC">ŸÜ</span> <span data-cp="918C" data-bytes="89 AB">‰«</span> <span data-cp="918E" data-bytes="9F B8">Ÿ¸</span> <span data-cp="91A9" data-bytes="90 70">�p</span> <span data-cp="91B6" data-bytes="8B 63">‹c</span> <span data-cp="91BB" data-bytes="95 DC">•Ü</span> <span data-cp="91C4" data-bytes="90 71">�q</span> <span data-cp="91D4" data-bytes="9B DE">›Þ</span> <span data-cp="91DF" data-bytes="89 49">‰I</span> <span data-cp="91E5" data-bytes="96 5B">–[</span> <span data-cp="91F6" data-bytes="8C 50">ŒP</span> <span data-cp="91FA" data-bytes="94 A6">”¦</span> <span data-cp="91FE" data-bytes="8F D5">�Õ</span> <span data-cp="9208" data-bytes="9E 73">žs</span> <span data-cp="920E" data-bytes="90 75">�u</span> <span data-cp="9213" data-bytes="99 F7">™÷</span> <span data-cp="9218" data-bytes="87 B2">‡²</span> <span data-cp="9221" data-bytes="8C BF">Œ¿</span> <span data-cp="9228" data-bytes="99 F9">™ù</span> <span data-cp="922A" data-bytes="96 63">–c</span> <span data-cp="922B" data-bytes="95 B9">•¹</span> <span data-cp="9235" data-bytes="94 D4">”Ô</span> <span data-cp="9241" data-bytes="90 77">�w</span> <span data-cp="9244" data-bytes="90 AB">�«</span> <span data-cp="9255" data-bytes="9D 4D">�M</span> <span data-cp="9258" data-bytes="99 FA">™ú</span> <span data-cp="925D" data-bytes="92 E3">’ã</span> <span data-cp="925F" data-bytes="97 BB">—»</span> <span data-cp="9262" data-bytes="90 78">�x</span> <span data-cp="926B" data-bytes="99 FB">™û</span> <span data-cp="926E" data-bytes="97 E0">—à</span> <span data-cp="9277" data-bytes="96 DC">–Ü</span> <span data-cp="9281" data-bytes="9C A8">œ¨</span> <span data-cp="9284" data-bytes="97 72">—r</span> <span data-cp="9289" data-bytes="94 40">”@</span> <span data-cp="928F" data-bytes="92 F2">’ò</span> <span data-cp="92AE" data-bytes="99 FD">™ý</span> <span data-cp="92B1" data-bytes="99 FC">™ü</span> <span data-cp="92B9" data-bytes="90 7A">�z</span> <span data-cp="92BA" data-bytes="96 4A">–J</span> <span data-cp="92BE" data-bytes="96 D8">–Ø</span> <span data-cp="92BF" data-bytes="99 FE">™þ</span> <span data-cp="92D4" data-bytes="90 4B">�K</span> <span data-cp="92E3" data-bytes="9A 40">š@</span> <span data-cp="92E5" data-bytes="97 5B">—[</span> <span data-cp="92EB" data-bytes="9A 41">šA</span> <span data-cp="92EC" data-bytes="91 DD">‘Ý</span> <span data-cp="92F2" data-bytes="93 FC">“ü</span> <span data-cp="92F3" data-bytes="9A 42">šB</span> <span data-cp="92F4" data-bytes="9A 43">šC</span> <span data-cp="92F6" data-bytes="96 59">–Y</span> <span data-cp="92FD" data-bytes="9A 44">šD</span> <span data-cp="9303" data-bytes="90 51">�Q</span> <span data-cp="9307" data-bytes="94 BF">”¿</span> <span data-cp="932C" data-bytes="90 A2">�¢</span> <span data-cp="9330" data-bytes="9C AB">œ«</span> <span data-cp="9331" data-bytes="97 76">—v</span> <span data-cp="9342" data-bytes="94 A8">”¨</span> <span data-cp="9343" data-bytes="9A 45">šE</span> <span data-cp="9345" data-bytes="9D E1">�á</span> <span data-cp="9348" data-bytes="96 D9">–Ù</span> <span data-cp="935F" data-bytes="97 74">—t</span> <span data-cp="9366" data-bytes="92 E5">’å</span> <span data-cp="9368" data-bytes="96 45">–E</span> <span data-cp="9369" data-bytes="91 DA">‘Ú</span> <span data-cp="936B" data-bytes="90 A3">�£</span> <span data-cp="936E" data-bytes="92 C8">’È</span> <span data-cp="9373" data-bytes="90 AF">�¯</span> <span data-cp="9374" data-bytes="97 BF">—¿</span> <span data-cp="9378" data-bytes="91 4C">‘L</span> <span data-cp="937D" data-bytes="96 7A">–z</span> <span data-cp="9381" data-bytes="91 DE">‘Þ</span> <span data-cp="9384" data-bytes="9A 46">šF</span> <span data-cp="9386" data-bytes="97 79">—y</span> <span data-cp="9387" data-bytes="94 6C">”l</span> <span data-cp="9390" data-bytes="98 58">˜X</span> <span data-cp="939C" data-bytes="92 66">’f</span> <span data-cp="93A0" data-bytes="93 FB">“û</span> <span data-cp="93AD" data-bytes="9A 47">šG</span> <span data-cp="93B8" data-bytes="97 49">—I</span> <span data-cp="93BB" data-bytes="97 48">—H</span> <span data-cp="93BD" data-bytes="93 4A">“J</span> <span data-cp="93BF" data-bytes="9C E2">œâ</span> <span data-cp="93C6" data-bytes="92 64">’d</span> <span data-cp="93CB" data-bytes="91 DF">‘ß</span> <span data-cp="93DB" data-bytes="96 D7">–×</span> <span data-cp="93E0" data-bytes="93 43">“C</span> <span data-cp="93F3" data-bytes="91 DB">‘Û</span> <span data-cp="93F4" data-bytes="8C 6A">Œj</span> <span data-cp="9401" data-bytes="97 AF">—¯</span> <span data-cp="9404" data-bytes="95 DD">•Ý</span> <span data-cp="9408" data-bytes="93 48">“H</span> <span data-cp="9417" data-bytes="9A 4B">šK</span> <span data-cp="941D" data-bytes="9A 4D">šM</span> <span data-cp="9424" data-bytes="91 BC">‘¼</span> <span data-cp="9425" data-bytes="90 E2">�â</span> <span data-cp="9426" data-bytes="90 B4">�´</span> <span data-cp="9427" data-bytes="95 E1">•á</span> <span data-cp="942D" data-bytes="9A 4E">šN</span> <span data-cp="942F" data-bytes="87 AD">‡­</span> <span data-cp="943E" data-bytes="9A 4F">šO</span> <span data-cp="944D" data-bytes="96 DD">–Ý</span> <span data-cp="9454" data-bytes="9A 51">šQ</span> <span data-cp="9458" data-bytes="96 A7">–§</span> <span data-cp="945B" data-bytes="90 B0">�°</span> <span data-cp="9465" data-bytes="9C 4E">œN</span> <span data-cp="9467" data-bytes="94 43">”C</span> <span data-cp="946C" data-bytes="8E BA">Žº</span> <span data-cp="9479" data-bytes="9A 52">šR</span> <span data-cp="9485" data-bytes="8B E9">‹é</span> <span data-cp="949F" data-bytes="9C AF">œ¯</span> <span data-cp="94A2" data-bytes="8B FD">‹ý</span> <span data-cp="94C1" data-bytes="9A BC">š¼</span> <span data-cp="94C3" data-bytes="9A B8">š¸</span> <span data-cp="94DC" data-bytes="9A AE">š®</span> <span data-cp="94F6" data-bytes="9A A7">š§</span> <span data-cp="952D" data-bytes="9A 53">šS</span> <span data-cp="9547" data-bytes="9D 74">�t</span> <span data-cp="9578" data-bytes="8B EA">‹ê</span> <span data-cp="957F" data-bytes="8B EB">‹ë</span> <span data-cp="9585" data-bytes="90 B2">�²</span> <span data-cp="9596" data-bytes="95 E9">•é</span> <span data-cp="9597" data-bytes="95 E8">•è</span> <span data-cp="9599" data-bytes="95 E6">•æ</span> <span data-cp="95A0" data-bytes="90 B5">�µ</span> <span data-cp="95A2" data-bytes="9A 54">šT</span> <span data-cp="95A6" data-bytes="90 B3">�³</span> <span data-cp="95A7" data-bytes="95 E7">•ç</span> <span data-cp="95AA" data-bytes="8B 50">‹P</span> <span data-cp="95E8" data-bytes="8B EC">‹ì</span> <span data-cp="95F4" data-bytes="9A 56">šV</span> <span data-cp="961D" data-bytes="8B FB">‹û</span> <span data-cp="9633" data-bytes="9A 57">šW</span> <span data-cp="9638" data-bytes="A0 AA"> ª</span> <span data-cp="9641" data-bytes="9F A6">Ÿ¦</span> <span data-cp="9645" data-bytes="99 CC">™Ì</span> <span data-cp="9656" data-bytes="9C 59">œY</span> <span data-cp="9669" data-bytes="99 B5">™µ</span> <span data-cp="967B" data-bytes="90 BE">�¾</span> <span data-cp="9681" data-bytes="9F AF">Ÿ¯</span> <span data-cp="968F" data-bytes="95 F2">•ò</span> <span data-cp="9696" data-bytes="90 BF">�¿</span> <span data-cp="96A3" data-bytes="90 C1">�Á</span> <span data-cp="96B6" data-bytes="90 C4">�Ä</span> <span data-cp="96BD" data-bytes="90 C7">�Ç</span> <span data-cp="96F4" data-bytes="92 E4">’ä</span> <span data-cp="9703" data-bytes="9F 52">ŸR</span> <span data-cp="971B" data-bytes="90 DB">�Û</span> <span data-cp="9721" data-bytes="A0 66"> f</span> <span data-cp="9731" data-bytes="90 D2">�Ò</span> <span data-cp="9734" data-bytes="87 6B">‡k</span> <span data-cp="9736" data-bytes="90 D4">�Ô</span> <span data-cp="9740" data-bytes="9A 5B">š[</span> <span data-cp="9741" data-bytes="95 FD">•ý</span> <span data-cp="974A" data-bytes="87 B1">‡±</span> <span data-cp="9751" data-bytes="8B C4">‹Ä</span> <span data-cp="9755" data-bytes="8C 66">Œf</span> <span data-cp="9757" data-bytes="90 DE">�Þ</span> <span data-cp="975C" data-bytes="90 DC">�Ü</span> <span data-cp="975D" data-bytes="96 44">–D</span> <span data-cp="975F" data-bytes="90 E1">�á</span> <span data-cp="976D" data-bytes="9E 46">žF</span> <span data-cp="9771" data-bytes="96 51">–Q</span> <span data-cp="9789" data-bytes="90 E6">�æ</span> <span data-cp="979B" data-bytes="96 50">–P</span> <span data-cp="979F" data-bytes="90 E7">�ç</span> <span data-cp="97B1" data-bytes="90 E8">�è</span> <span data-cp="97B2" data-bytes="9A 5D">š]</span> <span data-cp="97B4" data-bytes="9F 7A">Ÿz</span> <span data-cp="97B8" data-bytes="9B 5C">›\</span> <span data-cp="97BA" data-bytes="9F 7C">Ÿ|</span> <span data-cp="97BE" data-bytes="90 E9">�é</span> <span data-cp="97C0" data-bytes="90 EA">�ê</span> <span data-cp="97C2" data-bytes="9A 5E">š^</span> <span data-cp="97C8" data-bytes="9F 76">Ÿv</span> <span data-cp="97D2" data-bytes="90 EB">�ë</span> <span data-cp="97E0" data-bytes="90 EC">�ì</span> <span data-cp="97E6" data-bytes="8B EE">‹î</span> <span data-cp="97EE" data-bytes="90 EE">�î</span> <span data-cp="97F2" data-bytes="91 C6">‘Æ</span> <span data-cp="97F5" data-bytes="90 F2">�ò</span> <span data-cp="97FF" data-bytes="90 F1">�ñ</span> <span data-cp="9815" data-bytes="8A 74">Št</span> <span data-cp="981F" data-bytes="96 57">–W</span> <span data-cp="9823" data-bytes="9C EF">œï</span> <span data-cp="982E" data-bytes="9F DF">Ÿß</span> <span data-cp="9833" data-bytes="90 F7">�÷</span> <span data-cp="9834" data-bytes="90 F6">�ö</span> <span data-cp="9847" data-bytes="9B 5E">›^</span> <span data-cp="984B" data-bytes="90 F8">�ø</span> <span data-cp="9856" data-bytes="8C FC">Œü</span> <span data-cp="9866" data-bytes="90 F9">�ù</span> <span data-cp="9868" data-bytes="8C C9">ŒÉ</span> <span data-cp="9875" data-bytes="8B EF">‹ï</span> <span data-cp="98B4" data-bytes="9F E0">Ÿà</span> <span data-cp="98B7" data-bytes="91 42">‘B</span> <span data-cp="98B9" data-bytes="9A 62">šb</span> <span data-cp="98C3" data-bytes="95 69">•i</span> <span data-cp="98C7" data-bytes="91 44">‘D</span> <span data-cp="98C8" data-bytes="91 43">‘C</span> <span data-cp="98CA" data-bytes="91 41">‘A</span> <span data-cp="98CE" data-bytes="8B F0">‹ð</span> <span data-cp="98DC" data-bytes="96 60">–`</span> <span data-cp="98DE" data-bytes="8B F1">‹ñ</span> <span data-cp="98E0" data-bytes="99 F6">™ö</span> <span data-cp="98E1" data-bytes="91 49">‘I</span> <span data-cp="98E6" data-bytes="91 4A">‘J</span> <span data-cp="98EC" data-bytes="91 4B">‘K</span> <span data-cp="98F1" data-bytes="9A 64">šd</span> <span data-cp="98F5" data-bytes="8A BF">Š¿</span> <span data-cp="990E" data-bytes="9A 66">šf</span> <span data-cp="9919" data-bytes="9A 67">šg</span> <span data-cp="991C" data-bytes="9A 69">ši</span> <span data-cp="9937" data-bytes="9A 6A">šj</span> <span data-cp="9938" data-bytes="96 52">–R</span> <span data-cp="9939" data-bytes="91 4D">‘M</span> <span data-cp="993B" data-bytes="96 66">–f</span> <span data-cp="9940" data-bytes="9F 7B">Ÿ{</span> <span data-cp="9942" data-bytes="9A 6B">šk</span> <span data-cp="994A" data-bytes="A0 6C"> l</span> <span data-cp="994D" data-bytes="96 67">–g</span> <span data-cp="995D" data-bytes="9A 6C">šl</span> <span data-cp="9962" data-bytes="9A 6D">šm</span> <span data-cp="9963" data-bytes="8B F2">‹ò</span> <span data-cp="999B" data-bytes="96 6A">–j</span> <span data-cp="99AA" data-bytes="96 6C">–l</span> <span data-cp="99B8" data-bytes="91 C4">‘Ä</span> <span data-cp="99BC" data-bytes="96 77">–w</span> <span data-cp="99C4" data-bytes="99 F4">™ô</span> <span data-cp="99C5" data-bytes="9A 6F">šo</span> <span data-cp="99D6" data-bytes="9B C6">›Æ</span> <span data-cp="99DA" data-bytes="9F AB">Ÿ«</span> <span data-cp="99E0" data-bytes="8C BE">Œ¾</span> <span data-cp="99E1" data-bytes="8E C1">ŽÁ</span> <span data-cp="99E6" data-bytes="95 55">•U</span> <span data-cp="99F5" data-bytes="91 52">‘R</span> <span data-cp="9A0C" data-bytes="91 53">‘S</span> <span data-cp="9A10" data-bytes="91 55">‘U</span> <span data-cp="9A1F" data-bytes="95 5D">•]</span> <span data-cp="9A21" data-bytes="96 71">–q</span> <span data-cp="9A26" data-bytes="9C 6D">œm</span> <span data-cp="9A2F" data-bytes="96 73">–s</span> <span data-cp="9A3B" data-bytes="91 54">‘T</span> <span data-cp="9A3C" data-bytes="9A 71">šq</span> <span data-cp="9A58" data-bytes="91 56">‘V</span> <span data-cp="9A5C" data-bytes="96 6D">–m</span> <span data-cp="9A63" data-bytes="95 57">•W</span> <span data-cp="9A6C" data-bytes="89 C6">‰Æ</span> <span data-cp="9A8F" data-bytes="89 C7">‰Ç</span> <span data-cp="9AB2" data-bytes="8A 6A">Šj</span> <span data-cp="9AB6" data-bytes="8B 57">‹W</span> <span data-cp="9ABA" data-bytes="9F E1">Ÿá</span> <span data-cp="9ABD" data-bytes="9B 5F">›_</span> <span data-cp="9AD7" data-bytes="A0 5D"> ]</span> <span data-cp="9AE0" data-bytes="91 5B">‘[</span> <span data-cp="9AE2" data-bytes="91 5C">‘\</span> <span data-cp="9AF4" data-bytes="91 5E">‘^</span> <span data-cp="9AFF" data-bytes="9F 5C">Ÿ\</span> <span data-cp="9B02" data-bytes="9F 57">ŸW</span> <span data-cp="9B09" data-bytes="9F 65">Ÿe</span> <span data-cp="9B0F" data-bytes="9A 72">šr</span> <span data-cp="9B14" data-bytes="91 60">‘`</span> <span data-cp="9B2A" data-bytes="9F 5E">Ÿ^</span> <span data-cp="9B2D" data-bytes="91 61">‘a</span> <span data-cp="9B2E" data-bytes="9F 60">Ÿ`</span> <span data-cp="9B34" data-bytes="91 64">‘d</span> <span data-cp="9B39" data-bytes="9F 41">ŸA</span> <span data-cp="9B40" data-bytes="91 69">‘i</span> <span data-cp="9B50" data-bytes="91 68">‘h</span> <span data-cp="9B69" data-bytes="9A 74">št</span> <span data-cp="9B7F" data-bytes="96 B2">–²</span> <span data-cp="9B81" data-bytes="9A 75">šu</span> <span data-cp="9B8B" data-bytes="9E E9">žé</span> <span data-cp="9B8D" data-bytes="8B BA">‹º</span> <span data-cp="9B8E" data-bytes="91 6D">‘m</span> <span data-cp="9B8F" data-bytes="A0 60"> `</span> <span data-cp="9B97" data-bytes="9F DE">ŸÞ</span> <span data-cp="9B9D" data-bytes="9F C3">ŸÃ</span> <span data-cp="9B9F" data-bytes="96 B5">–µ</span> <span data-cp="9BB0" data-bytes="A0 67"> g</span> <span data-cp="9BCF" data-bytes="96 B3">–³</span> <span data-cp="9BDD" data-bytes="9A 76">šv</span> <span data-cp="9BE9" data-bytes="95 D5">•Õ</span> <span data-cp="9BED" data-bytes="9E CA">žÊ</span> <span data-cp="9BF1" data-bytes="9A 77">šw</span> <span data-cp="9BF4" data-bytes="9A 78">šx</span> <span data-cp="9BFF" data-bytes="91 70">‘p</span> <span data-cp="9C02" data-bytes="91 6F">‘o</span> <span data-cp="9C0A" data-bytes="9F A3">Ÿ£</span> <span data-cp="9C0C" data-bytes="91 71">‘q</span> <span data-cp="9C10" data-bytes="96 B1">–±</span> <span data-cp="9C15" data-bytes="9F 63">Ÿc</span> <span data-cp="9C1B" data-bytes="9F 67">Ÿg</span> <span data-cp="9C1F" data-bytes="8B B9">‹¹</span> <span data-cp="9C20" data-bytes="9A 7A">šz</span> <span data-cp="9C26" data-bytes="8B 56">‹V</span> <span data-cp="9C2F" data-bytes="9A DA">šÚ</span> <span data-cp="9C35" data-bytes="96 B0">–°</span> <span data-cp="9C3A" data-bytes="9A 7E">š~</span> <span data-cp="9C45" data-bytes="9D DE">�Þ</span> <span data-cp="9C4F" data-bytes="96 AD">–­</span> <span data-cp="9C53" data-bytes="96 AE">–®</span> <span data-cp="9C5D" data-bytes="9E A1">ž¡</span> <span data-cp="9C72" data-bytes="9E 50">žP</span> <span data-cp="9C7B" data-bytes="96 AF">–¯</span> <span data-cp="9C7C" data-bytes="8B F4">‹ô</span> <span data-cp="9D02" data-bytes="9F A4">Ÿ¤</span> <span data-cp="9D0C" data-bytes="96 BD">–½</span> <span data-cp="9D16" data-bytes="96 F4">–ô</span> <span data-cp="9D21" data-bytes="96 B8">–¸</span> <span data-cp="9D39" data-bytes="91 A7">‘§</span> <span data-cp="9D44" data-bytes="A0 5E"> ^</span> <span data-cp="9D49" data-bytes="9A 7D">š}</span> <span data-cp="9D4E" data-bytes="89 48">‰H</span> <span data-cp="9D50" data-bytes="9E B1">ž±</span> <span data-cp="9D5E" data-bytes="9D DB">�Û</span> <span data-cp="9D6D" data-bytes="95 BF">•¿</span> <span data-cp="9D6E" data-bytes="8A 73">Šs</span> <span data-cp="9D7C" data-bytes="9E FE">žþ</span> <span data-cp="9D7E" data-bytes="91 7A">‘z</span> <span data-cp="9D83" data-bytes="91 7B">‘{</span> <span data-cp="9D93" data-bytes="9A A3">š£</span> <span data-cp="9DA5" data-bytes="96 C2">–Â</span> <span data-cp="9DAB" data-bytes="9F 77">Ÿw</span> <span data-cp="9DBD" data-bytes="9A A4">š¤</span> <span data-cp="9DC0" data-bytes="9A A5">š¥</span> <span data-cp="9DC4" data-bytes="91 A1">‘¡</span> <span data-cp="9DC9" data-bytes="89 B8">‰¸</span> <span data-cp="9DD4" data-bytes="91 73">‘s</span> <span data-cp="9DF0" data-bytes="9C 6B">œk</span> <span data-cp="9DFC" data-bytes="9A A6">š¦</span> <span data-cp="9E0A" data-bytes="89 BD">‰½</span> <span data-cp="9E0C" data-bytes="89 B9">‰¹</span> <span data-cp="9E0E" data-bytes="91 7D">‘}</span> <span data-cp="9E18" data-bytes="96 BB">–»</span> <span data-cp="9E1C" data-bytes="9F F2">Ÿò</span> <span data-cp="9E1F" data-bytes="8B F5">‹õ</span> <span data-cp="9E7B" data-bytes="9A A9">š©</span> <span data-cp="9E81" data-bytes="9F 54">ŸT</span> <span data-cp="9E84" data-bytes="9F E3">Ÿã</span> <span data-cp="9E85" data-bytes="9E ED">ží</span> <span data-cp="9E90" data-bytes="91 AA">‘ª</span> <span data-cp="9E95" data-bytes="91 AB">‘«</span> <span data-cp="9E96" data-bytes="A0 70"> p</span> <span data-cp="9E98" data-bytes="9F 6D">Ÿm</span> <span data-cp="9E9E" data-bytes="91 AC">‘¬</span> <span data-cp="9EA2" data-bytes="91 AD">‘­</span> <span data-cp="9EA6" data-bytes="A0 FD"> ý</span> <span data-cp="9EA8" data-bytes="9F E2">Ÿâ</span> <span data-cp="9EAA" data-bytes="91 AF">‘¯</span> <span data-cp="9EAB" data-bytes="9E 41">žA</span> <span data-cp="9EAC" data-bytes="9A AA">šª</span> <span data-cp="9EAF" data-bytes="91 B0">‘°</span> <span data-cp="9EB1" data-bytes="9A AB">š«</span> <span data-cp="9EBD" data-bytes="9A AC">š¬</span> <span data-cp="9EBF" data-bytes="9A 4A">šJ</span> <span data-cp="9EC1" data-bytes="91 B2">‘²</span> <span data-cp="9EC4" data-bytes="8B F6">‹ö</span> <span data-cp="9EC6" data-bytes="9A AD">š­</span> <span data-cp="9EC7" data-bytes="89 B6">‰¶</span> <span data-cp="9EE2" data-bytes="9A AF">š¯</span> <span data-cp="9EF1" data-bytes="9A B0">š°</span> <span data-cp="9EF8" data-bytes="9A B1">š±</span> <span data-cp="9EFE" data-bytes="9A A1">š¡</span> <span data-cp="9F02" data-bytes="91 B9">‘¹</span> <span data-cp="9F08" data-bytes="91 BA">‘º</span> <span data-cp="9F16" data-bytes="91 BF">‘¿</span> <span data-cp="9F17" data-bytes="91 BE">‘¾</span> <span data-cp="9F26" data-bytes="A0 41"> A</span> <span data-cp="9F27" data-bytes="8B B7">‹·</span> <span data-cp="9F39" data-bytes="91 C0">‘À</span> <span data-cp="9F44" data-bytes="9A B3">š³</span> <span data-cp="9F45" data-bytes="91 C3">‘Ã</span> <span data-cp="9F50" data-bytes="A0 FC"> ü</span> <span data-cp="9F53" data-bytes="9F EE">Ÿî</span> <span data-cp="9F5A" data-bytes="9F 69">Ÿi</span> <span data-cp="9F62" data-bytes="91 C8">‘È</span> <span data-cp="9F69" data-bytes="91 C9">‘É</span> <span data-cp="9F7F" data-bytes="8D E6">�æ</span> <span data-cp="9F8E" data-bytes="91 CB">‘Ë</span> <span data-cp="9F96" data-bytes="87 AC">‡¬</span> <span data-cp="9F97" data-bytes="87 A4">‡¤</span> <span data-cp="9F99" data-bytes="89 C8">‰È</span> <span data-cp="9F9F" data-bytes="8D AA">�ª</span> <span data-cp="9FA5" data-bytes="9F DD">ŸÝ</span> <span data-cp="9FA6" data-bytes="8C 43">ŒC</span> <span data-cp="9FA7" data-bytes="8C 6D">Œm</span> <span data-cp="9FA8" data-bytes="8C 74">Œt</span> <span data-cp="9FA9" data-bytes="8C B7">Œ·</span> <span data-cp="9FAA" data-bytes="8C B9">Œ¹</span> <span data-cp="9FAB" data-bytes="8C BB">Œ»</span> <span data-cp="9FAC" data-bytes="8C C0">ŒÀ</span> <span data-cp="9FAD" data-bytes="8C D7">Œ×</span> <span data-cp="9FAE" data-bytes="8C D8">ŒØ</span> <span data-cp="9FAF" data-bytes="8C DA">ŒÚ</span> <span data-cp="9FB2" data-bytes="8C ED">Œí</span> <span data-cp="9FB3" data-bytes="8D 48">�H</span> <span data-cp="9FC7" data-bytes="87 C2">‡Â</span> <span data-cp="9FC8" data-bytes="87 D2">‡Ò</span> <span data-cp="9FC9" data-bytes="87 D6">‡Ö</span> <span data-cp="9FCA" data-bytes="87 DA">‡Ú</span> <span data-cp="9FCB" data-bytes="87 DF">‡ß</span> <span data-cp="F907" data-bytes="8B F8">‹ø</span> </body></html>
diff --git a/benchmarks/data/wpt/weighted/fetch.http.html b/benchmarks/data/wpt/weighted/fetch.http.html
new file mode 100644
index 00000000..d0cb7206
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/fetch.http.html
@@ -0,0 +1,143 @@
+<!DOCTYPE html>
+<!-- DO NOT EDIT! Generated by `common/security-features/tools/generate.py --spec referrer-policy/4K-1/` -->
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="timeout" content="long">
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script src="/common/security-features/resources/common.sub.js"></script>
+    <script src="../../../../generic/test-case.sub.js"></script>
+    <script src="../../../generic/test-case.sub.js"></script>
+  </head>
+  <body>
+    <script>
+      TestCase(
+        [
+          {
+            "expectation": "stripped-referrer",
+            "origin": "cross-http",
+            "redirection": "keep-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to cross-http origin and keep-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "cross-http",
+            "redirection": "no-redirect",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to cross-http origin and no-redirect redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "cross-http",
+            "redirection": "swap-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to cross-http origin and swap-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "cross-https",
+            "redirection": "keep-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to cross-https origin and keep-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "cross-https",
+            "redirection": "no-redirect",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to cross-https origin and no-redirect redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "cross-https",
+            "redirection": "swap-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to cross-https origin and swap-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "same-http",
+            "redirection": "keep-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to same-http origin and keep-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "same-http",
+            "redirection": "no-redirect",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to same-http origin and no-redirect redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "same-http",
+            "redirection": "swap-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to same-http origin and swap-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "same-https",
+            "redirection": "keep-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to same-https origin and keep-origin redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "same-https",
+            "redirection": "no-redirect",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to same-https origin and no-redirect redirection from http context."
+          },
+          {
+            "expectation": "stripped-referrer",
+            "origin": "same-https",
+            "redirection": "swap-origin",
+            "source_context_list": [],
+            "source_scheme": "http",
+            "subresource": "fetch",
+            "subresource_policy_deliveries": [],
+            "test_description": "Referrer Policy: Expects stripped-referrer for fetch to same-https origin and swap-origin redirection from http context."
+          }
+        ],
+        new SanityChecker()
+      ).start();
+    </script>
+    <div id="log"></div>
+  </body>
+</html>
diff --git a/benchmarks/data/wpt/weighted/filter-turbulence-invalid-001.html b/benchmarks/data/wpt/weighted/filter-turbulence-invalid-001.html
new file mode 100644
index 00000000..7400c8b3
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/filter-turbulence-invalid-001.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<title>CSS Filter Effects: feTurbulence with negative values from baseFrequency</title>
+<link rel="help" href="https://drafts.fxtf.org/filter-effects/#element-attrdef-feturbulence-basefrequency">
+<link rel="help" href="https://crbug.com/1068863"/>
+<link rel="match" href="reference/filter-turbulence-invalid-001-ref.html">
+<meta name="assert" content="This test checks that negative baseFrequency values are unsupported for feTurbulence.">
+<style>
+.target {
+  display: inline-block;
+  width: 100px;
+  height: 100px;
+  background-color: red;
+}
+</style>
+<div class="target" style="filter: url(#fn1)"></div>
+<div class="target" style="filter: url(#fn2)"></div>
+<div class="target" style="filter: url(#tb1)"></div>
+<div class="target" style="filter: url(#tb2)"></div>
+<svg height="0" color-interpolation-filters="sRGB">
+    <!-- type=fractalNoise -->
+    <filter id="fn1" x="0" y="0" width="1" height="1">
+        <feTurbulence type="fractalNoise" baseFrequency="-1 1"/>
+        <feComponentTransfer>
+            <feFuncR type="discrete" tableValues="1 0 1"/>
+            <feFuncG type="discrete" tableValues="0 0.502 0"/> <!-- map [0..1/3] -> 0; [1/3...2/3] -> 0.502; [2/3..1] -> 0 -->
+            <feFuncB type="discrete" tableValues="0"/>
+            <feFuncA type="discrete" tableValues="0 1 0"/>
+        </feComponentTransfer>
+    </filter>
+
+    <filter id="fn2" x="0" y="0" width="1" height="1">
+        <feTurbulence type="fractalNoise" baseFrequency="1 -1"/>
+        <feComponentTransfer>
+            <feFuncR type="discrete" tableValues="1 0 1"/>
+            <feFuncG type="discrete" tableValues="0 0.502 0"/> <!-- map [0..1/3] -> 0; [1/3...2/3] -> 0.502; [2/3..1] -> 0 -->
+            <feFuncB type="discrete" tableValues="0"/>
+            <feFuncA type="discrete" tableValues="0 1 0"/>
+        </feComponentTransfer>
+    </filter>
+
+    <!-- type=turbulence -->
+    <filter id="tb1" x="0" y="0" width="1" height="1">
+        <feTurbulence type="turbulence" baseFrequency="-1 1"/>
+        <feColorMatrix values="1 0 0 0 0, 0 1 0 0 0.502, 0 0 1 0 0, 0 0 0 1 1"/>
+    </filter>
+
+    <filter id="tb2" x="0" y="0" width="1" height="1">
+        <feTurbulence type="turbulence" baseFrequency="1 -1"/>
+        <feColorMatrix values="1 0 0 0 0, 0 1 0 0 0.502, 0 0 1 0 0, 0 0 0 1 1"/>
+    </filter>
+</svg>
diff --git a/benchmarks/data/wpt/weighted/grid-auto-fill-rows-001.html b/benchmarks/data/wpt/weighted/grid-auto-fill-rows-001.html
new file mode 100644
index 00000000..afce3f5f
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/grid-auto-fill-rows-001.html
@@ -0,0 +1,184 @@
+<!DOCTYPE html>
+<title>CSS Grid: auto-fill rows</title>
+<link rel="author" title="Sergio Villar" href="mailto: svillar@igalia.com">
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#valdef-repeat-auto-fill">
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#propdef-grid-auto-columns">
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#propdef-grid-auto-rows">
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#propdef-grid-template-rows">
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#propdef-grid-row">
+<link rel="help" href="https://drafts.csswg.org/css-align-3/#propdef-grid-row-gap">
+<link rel="help" href="https://crbug.com/619930">
+<link rel="help" href="https://crbug.com/589460">
+<link rel="help" href="https://crbug.com/648814">
+<meta name="assert" content="Check that auto-fill rows are properly computed in a grid container"/>
+<link href="/css/support/grid.css" rel="stylesheet">
+<style>
+
+.grid {
+    border: 2px solid magenta;
+    height: 200px;
+    width: 25px;
+    align-content: start;
+    grid-auto-rows: 157px;
+    grid-auto-columns: 25px;
+
+    float: left;
+    position: relative;
+    margin-right: 2px;
+}
+
+.gridOnlyAutoRepeat { grid-template-rows: repeat(auto-fill, 30px [autobar]); }
+.gridAutoRepeatAndFixedBefore { grid-template-rows: 10px [foo] 20% [bar] repeat(auto-fill, [autofoo] 35px); }
+.gridAutoRepeatAndFixedAfter { grid-template-rows: repeat(auto-fill, [first] 30px [last]) [foo] minmax(60px, 80px) [bar] minmax(45px, max-content); }
+.gridAutoRepeatAndFixed { grid-template-rows: [start] repeat(2, 50px [a]) [middle] repeat(auto-fill, [autofoo] 15px [autobar]) minmax(5%, 10%) [end]; }
+.gridMultipleNames { grid-template-rows: [start] 20px [foo] 50% repeat(auto-fill, [bar] 20px [start foo]) [foo] 10% [end bar]; }
+.gridMultipleTracks { grid-template-rows: [start] 20px repeat(auto-fill, [a] 2em [b c] 10% [d]) [e] minmax(75px, 1fr) [last]; }
+
+.item { background-color: blue; }
+.item:nth-child(2) { background: green; }
+.item:nth-child(3) { background: orange; }
+
+.gap { grid-row-gap: 20px; }
+
+</style>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+
+<body onload="checkLayout('.grid')">
+<div id="log"></div>
+
+<p>This test checks that repeat(auto-fill, ) syntax works as expected.</p>
+
+<div class="grid gridOnlyAutoRepeat">
+    <div class="item" style="grid-row: 1 / span 6" data-offset-y="0" data-offset-x="0" data-expected-height="180" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridOnlyAutoRepeat">
+    <div class="item" style="grid-row: 1 / span 6 autobar" data-offset-y="0" data-offset-x="0" data-expected-height="180" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridOnlyAutoRepeat gap">
+    <div class="item" style="grid-row: 1 / span 5" data-offset-y="0" data-offset-x="0" data-expected-height="357" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridOnlyAutoRepeat gap">
+    <div class="item" style="grid-row: autobar 2 / span 3" data-offset-y="100" data-offset-x="0" data-expected-height="257" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridOnlyAutoRepeat gap" style="height: auto; max-height: 90px;" data-expected-height="94" data-expected-width="29">
+    <div class="item" data-offset-y="0" data-offset-x="0" data-expected-height="30" data-expected-width="25"></div>
+    <div class="item" data-offset-y="50" data-offset-x="0" data-expected-height="30" data-expected-width="25"></div>
+    <div class="item" data-offset-y="100" data-offset-x="0" data-expected-height="157" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridOnlyAutoRepeat gap" style="height: auto; max-height: 90px; min-height: 130px;" data-expected-height="134" data-expected-width="29">
+    <div class="item" data-offset-y="0" data-offset-x="0" data-expected-height="30" data-expected-width="25"></div>
+    <div class="item" data-offset-y="50" data-offset-x="0" data-expected-height="30" data-expected-width="25"></div>
+    <div class="item" data-offset-y="100" data-offset-x="0" data-expected-height="30" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedBefore">
+    <div class="item" style="grid-row: 1 / span 6" data-offset-y="0" data-offset-x="0" data-expected-height="190" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedBefore">
+    <div class="item" style="grid-row: foo / autofoo" data-offset-y="10" data-offset-x="0" data-expected-height="40" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedBefore">
+    <div class="item" style="grid-row: bar / 5 autofoo" data-offset-y="50" data-offset-x="0" data-expected-height="297" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedBefore gap">
+    <div class="item" style="grid-row: 1 / span 4" data-offset-y="0" data-offset-x="0" data-expected-height="180" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedBefore gap">
+    <div class="item" style="grid-row: span 3 / 2 autofoo" data-offset-y="0" data-offset-x="0" data-expected-height="125" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedBefore gap">
+    <div class="item" style="grid-row: notPresent / 3 autofoo" data-offset-y="377" data-offset-x="0" data-expected-height="157" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedAfter">
+    <div class="item" style="grid-row: 1 / span 4" data-offset-y="0" data-offset-x="0" data-expected-height="185" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedAfter">
+    <div class="item" style="grid-row: first / last 2" data-offset-y="0" data-offset-x="0" data-expected-height="60" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedAfter">
+    <div class="item" style="grid-row: last 2 / foo" data-offset-y="60" data-offset-x="0" data-expected-height="80" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedAfter gap">
+    <div class="item" style="grid-row: 1 / span 3" data-offset-y="0" data-offset-x="0" data-expected-height="195" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedAfter gap">
+    <div class="item" style="grid-row: 3 / span 1 bar" data-offset-y="130" data-offset-x="0" data-expected-height="222" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixedAfter gap">
+    <div class="item" style="grid-row: first / foo" data-offset-y="0" data-offset-x="0" data-expected-height="30" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixed">
+    <div class="item" style="grid-row: 1 / span 8" data-offset-y="0" data-offset-x="0" data-expected-height="195" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixed">
+    <div class="item" style="grid-row: a / autobar 2" data-offset-y="50" data-offset-x="0" data-expected-height="80" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixed">
+    <div class="item" style="grid-row: autofoo / end" data-offset-y="100" data-offset-x="0" data-expected-height="95" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixed gap">
+    <div class="item" style="grid-row: 1 / span 4"  data-offset-y="0" data-offset-x="0" data-expected-height="195" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridAutoRepeatAndFixed gap">
+    <div class="item" style="grid-row: autobar / -1"  data-offset-y="175" data-offset-x="0" data-expected-height="20" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleNames">
+    <div class="item" style="grid-row: 1 / -1"  data-offset-y="0" data-offset-x="0" data-expected-height="200" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleNames">
+    <div class="item" style="grid-row: foo 3 / 4 bar"  data-offset-y="160" data-offset-x="0" data-expected-height="40" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleNames">
+    <div class="item" style="grid-row: -6 / span 2 start"  data-offset-y="20" data-offset-x="0" data-expected-height="140" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleNames gap">
+    <div class="item" style="grid-row: -4 / -2"  data-offset-y="40" data-offset-x="0" data-expected-height="140" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleNames gap">
+    <div class="item" style="grid-row: bar / foo 2"  data-offset-y="160" data-offset-x="0" data-expected-height="20" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleNames gap">
+    <div class="item" style="grid-row: foo / bar 2"  data-offset-y="40" data-offset-x="0" data-expected-height="180" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleTracks">
+    <div class="item" style="grid-row: a / 2 c"  data-offset-y="20" data-offset-x="0" data-expected-height="84" data-expected-width="25"></div>
+    <div class="item" style="grid-row: 3 / e; grid-column: 2;"  data-offset-y="52" data-offset-x="25" data-expected-height="72" data-expected-width="25"></div>
+</div>
+
+<div class="grid gridMultipleTracks gap">
+    <div class="item" style="grid-row: a / c"  data-offset-y="40" data-offset-x="0" data-expected-height="32" data-expected-width="25"></div>
+    <div class="item" style="grid-row: 3 / last; grid-column: 2;"  data-offset-y="92" data-offset-x="25" data-expected-height="115" data-expected-width="25"></div>
+</div>
+
+</body>
diff --git a/benchmarks/data/wpt/weighted/image-orientation-from-image-content-images-ref.html b/benchmarks/data/wpt/weighted/image-orientation-from-image-content-images-ref.html
new file mode 100644
index 00000000..c0d29909
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/image-orientation-from-image-content-images-ref.html
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>CSS Images Module Level 3: image-orientation: from-image for content images</title>
+<link rel="author" title="Stephen Chenney" href="mailto:schenney@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-images-3/#propdef-image-orientation">
+<style>
+    div.image {
+        display: inline-block;
+    }
+    div.container {
+        display: inline-block;
+        width: 100px;
+        vertical-align: top;
+    }
+    img {
+        width: 100px;
+        height: 100px;
+        background-repeat: no-repeat;
+    }
+    body {
+        overflow: hidden;
+    }
+</style>
+</head>
+<body >
+    <p>The images should rotate respecting their EXIF orientation because
+       image-orientation: from-image is specified.
+    </p>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-1-ul-pre-rotated.jpg)"></div>
+        <br>Normal
+    </div>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-2-ur-pre-rotated.jpg)"></div>
+        <br>Flipped horizontally
+    </div>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-3-lr-pre-rotated.jpg)"></div>
+        <br>Rotated 180&deg;
+    </div>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-4-lol-pre-rotated.jpg)"></div>
+        <br>Flipped vertically
+    </div>
+    <br>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-5-lu-pre-rotated.jpg)"></div>
+        <br>Rotated 90&deg; CCW and flipped vertically
+    </div>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-6-ru-pre-rotated.jpg)"></div>
+        <br>Rotated 90&deg; CW
+    </div>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-7-rl-pre-rotated.jpg)"></div>
+        <br>Rotated 90&deg; CW and flipped vertically
+    </div>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-8-llo-pre-rotated.jpg)"></div>
+        <br>Rotated 90&deg; CCW
+    </div>
+    <br>
+    <div class="container">
+        <img style="background-image: url(../support/exif-orientation-5-lu-pre-rotated.jpg)"></img>
+        <br>Rotated 90&deg; CCW and flipped vertically
+    </div>
+    <div class="container">
+        <img style="background-image: url(../support/exif-orientation-6-ru-pre-rotated.jpg)"></img>
+        <br>Rotated 90&deg; CW
+    </div>
+    <div class="container">
+        <img style="background-image: url(../support/exif-orientation-7-rl-pre-rotated.jpg)"></img>
+        <br>Rotated 90&deg; CW and flipped vertically
+    </div>
+    <div class="container">
+        <img style="background-image: url(../support/exif-orientation-8-llo-pre-rotated.jpg)"></img>
+        <br>Rotated 90&deg; CCW
+    </div>
+    <br>
+    <div class="container">
+        <div class="image" style="content: url(../support/exif-orientation-9-u-pre-rotated.jpg)"></div>
+        <br>Undefined (invalid value)
+    </div>
+</body>
+</html>
diff --git a/benchmarks/data/wpt/weighted/masonry-item-placement-006.html b/benchmarks/data/wpt/weighted/masonry-item-placement-006.html
new file mode 100644
index 00000000..0082d72d
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/masonry-item-placement-006.html
@@ -0,0 +1,149 @@
+<!DOCTYPE HTML>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html><head>
+  <meta charset="utf-8">
+  <title>CSS Grid Test: Masonry item placement</title>
+  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+  <link rel="help" href="https://drafts.csswg.org/css-grid-2">
+  <link rel="match" href="masonry-item-placement-006-ref.html">
+  <style>
+html,body {
+  color:black; background-color:white; font:15px/1 monospace; padding:0; margin:0;
+}
+
+grid {
+  display: inline-grid;
+  gap: 1px 2px;
+  grid-template-columns: repeat(4,20px);
+  grid-template-rows: masonry;
+  color: #444;
+  border: 1px solid;
+  padding: 2px;
+}
+
+item {
+  background-color: #444;
+  color: #fff;
+}
+.next > grid {
+  masonry-auto-flow: next;
+}
+</style>
+</head>
+<body>
+
+<grid>
+  <item style="padding-top:30px">1</item>
+  <item>2</item>
+  <item>3</item>
+  <item>4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item>3</item>
+  <item>4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item style="padding-top:30px">1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item>4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item style="grid-column:span 2">4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item style="grid-column:span 3">4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item style="grid-column:span 4">4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<span class="next">
+<grid>
+  <item style="padding-top:30px">1</item>
+  <item>2</item>
+  <item>3</item>
+  <item>4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item>3</item>
+  <item>4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item style="padding-top:30px">1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item>4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item style="grid-column:span 2">4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item style="grid-column:span 3">4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+
+<grid>
+  <item>1</item>
+  <item style="padding-top:30px">2</item>
+  <item style="padding-top:10px">3</item>
+  <item style="grid-column:span 4">4</item>
+  <item>5</item>
+  <item>6</item>
+</grid>
+</span>
+
+</body>
+</html>
diff --git a/benchmarks/data/wpt/weighted/moz-css21-table-page-break-inside-avoid-2.html b/benchmarks/data/wpt/weighted/moz-css21-table-page-break-inside-avoid-2.html
new file mode 100644
index 00000000..cc6a5593
--- /dev/null
+++ b/benchmarks/data/wpt/weighted/moz-css21-table-page-break-inside-avoid-2.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="en-US" class="reftest-paged">
+<head>
+  <title>CSS Test: CSS 2.1 page-break-inside:avoid</title>
+  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=685012">
+  <link rel="help" href="http://www.w3.org/TR/CSS21/page.html#propdef-page-break-inside">
+  <link rel="match" href="moz-css21-table-page-break-inside-avoid-2-ref.html">
+  <meta name="flags" content="paged">
+<style type="text/css">
+@page { size:5in 3in; margin:0.5in; }
+p { height: 1in; width: 1in; margin:0; background-color:blue; }
+.test { page-break-inside:avoid; }
+</style>
+</head>
+<body>
+<table border="1">
+<tbody>
+<tr><td><p>1</p></td></tr>
+</tbody>
+</table>
+<div style= "page-break-after: always"></div>
+<table border="1" class="test">
+<tbody></tbody>
+<tbody>
+<tr><td><p>2</p><p>3</p></td></tr>
+</tbody>
+</table>
+</body>
+</html>
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 @@
+<!DOCTYPE html>
+<title>Reference for position:sticky bottom constraint should behave correctly for &lt;th&gt; elements</title>
+
+<style>
+.group {
+  display: inline-block;
+  position: relative;
+  width: 150px;
+  height: 200px;
+}
+
+.scroller {
+  position: relative;
+  width: 100px;
+  height: 150px;
+  overflow-x: hidden;
+  overflow-y: auto;
+}
+
+.contents {
+  height: 550px;
+}
+
+.indicator {
+  position: absolute;
+  background-color: green;
+  left: 0;
+  height: 50px;
+  width: 50px;
+}
+</style>
+
+<script>
+window.addEventListener('load', function() {
+  document.getElementById('scroller1').scrollTop = 0;
+  document.getElementById('scroller2').scrollTop = 75;
+  document.getElementById('scroller3').scrollTop = 200;
+});
+</script>
+
+<div class="group">
+  <div id="scroller1" class="scroller">
+    <div class="indicator" style="top: 100px;"></div>
+    <div class="contents"></div>
+  </div>
+</div>
+
+<div class="group">
+  <div id="scroller2" class="scroller">
+    <div class="indicator" style="top: 150px;"></div>
+    <div class="contents"></div>
+  </div>
+</div>
+
+<div class="group">
+  <div id="scroller3" class="scroller">
+    <div class="indicator" style="top: 250px;"></div>
+    <div class="contents"></div>
+  </div>
+</div>
+
+<div>You should see three green boxes above. No red should be visible.</div>
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 @@
+<!DOCTYPE html>
+<title>CSS test preserved spaces and floats interaction</title>
+<link rel="author" title="Koji Ishii" href="kojii@chromium.org">
+<link rel="match" href="reference/pre-float-001-ref.html">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-property">
+<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
+<style>
+html {
+  font-family: Ahem;
+  font-size: 20px;
+  line-height: 1;
+}
+.container {
+  white-space: pre;
+  width: 10ch;
+  margin-bottom: 1em;
+}
+.float {
+  float: left;
+  width: 3ch;
+  height: 2em;
+  background: orange;
+}
+</style>
+<body>
+  <div class="float"></div>
+  <div class="container">123456 <br>123456</div>
+  <div class="float"></div>
+  <div class="container">1234567 <br>1234567</div>
+  <div class="float"></div>
+  <div class="container">1234567  <br>1234567</div>
+  <div class="float"></div>
+  <div class="container">1234567   <br>1234567</div>
+  <div class="float"></div>
+  <div class="container">12345678 <br>12345678</div>
+</body>
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 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Basic User Interface Test: resize initial value - none</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<link rel="author" title="Shiyou Tan" href="mailto:shiyoux.tan@intel.com">
+<link rel="help" title="8.1. 'resize' property" href="http://www.w3.org/TR/css3-ui/#resize">
+<meta name="flags" content="interact">
+<meta name="assert" content="Test checks that the resize property initial value is none">
+<style>
+  #test {
+    border: 2px solid blue;
+    height: 100px;
+    overflow: auto;
+    width: 100px;
+  }
+</style>
+<body>
+  <p>Test passes if <strong>neither</strong> the height <strong>nor</strong> the width of the blue border square can be adjusted(for instance by dragging the bottom-right corner).</p>
+  <div id="test"></div>
+</body>
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 @@
+
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>Compositing and Blending Test Plan</title>
+		<meta charset='utf-8'>
+		<script src='http://www.w3.org/Tools/respec/respec-w3c-common'
+						async class='remove'></script>
+		<script class='remove'>
+			var respecConfig = {
+					specStatus: "unofficial",
+					shortName:  "compositing-1-test-plan",
+					editors: [
+								{
+									name: "Mirela Budaes",
+									company: "Adobe Systems, Inc.",
+									companyURL: "http://www.adobe.com/"
+								},
+								{
+									name: "Horia Olaru",
+									company: "Adobe Systems, Inc.",
+									companyURL: "http://www.adobe.com/"
+								},
+								{
+									name: "Mihai Tica",
+									company: "Adobe Systems, Inc.",
+									companyURL: "http://www.adobe.com/"
+								},
+
+					]
+			};
+		</script>
+		<style>
+			table
+			{
+				border-collapse:collapse;
+			}
+			table, td, th
+			{
+				border:1px solid black;
+				padding: 13px;
+			}
+			table
+			{
+				width: 100%;
+			}
+			img
+			{
+				width: 400px;
+			}
+		</style>
+	</head>
+	<body>
+		<section id='abstract'>
+			<p>
+				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.
+			</p>
+			<p>
+				This document is not meant to replace the spec in determining the
+				normative and non-normative assertions to be tested, but rather
+				complement it.
+			</p>
+		</section>
+		<section>
+			<h2>Goals</h2>
+			<section>
+				<h3>Providing guidance on testing</h3>
+				<p>
+					In order to increase the quality of the test contributions, this
+					document offers a set of test cases description for conducting testing (see
+					<a href="#test-cases-description" class="sectionRef"></a>).
+				</p>
+			</section>
+			<section>
+				<h3>Creating automation-friendly tests</h3>
+				<p>
+					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 <code>testharness.js</code>). Even where manual tests
+					are absolutely necessary they should be written so that they can be
+					easily automated &ndash; 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.
+				</p>
+			</section>
+		</section>
+		<section>
+			<h2>Approach</h2>
+			<p>
+				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 <a href="#testig-areas" class="sectionRef"></a>
+				and having as guidance the test cases description from <a href="#test-cases-description" class="sectionRef"></a>.
+			</p>
+		</section>
+		<section>
+			<h2>Testing areas</h2>
+			<section>
+				<h3>Explicit testing areas</h3>
+					<p>
+					  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
+					  <a href="http://lists.w3.org/Archives/Public/www-style/">mailing
+					  list</a>.
+					</p>
+				<p>Below is the list of explicit testing areas:</p>
+				<ol>
+					<li>Proper parsing of the CSS properties and rendering according to the spec
+						<ul><code>mix-blend-mode</code></ul>
+						<ul><code>isolation</code></ul>
+						<ul><code>background-blend-mode</code></ul>
+					</li>
+					<li>SVG blending</li>
+					<li>Canvas 2D blending</li>
+				</ol>
+			</section>
+			<section>
+				<h3>Implicit testing areas</h3>
+				<p>
+				  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
+				  <a href="http://lists.w3.org/Archives/Public/www-style/">mailing
+				  list</a>.
+				</p>
+				<p>Below is the list of implicit testing areas:</p>
+				<ol>
+					<li>Blending different types of elements
+						<ul>
+							<li><code>&lt;video&gt;</code></li>
+							<li><code>&lt;canvas&gt;</code></li>
+							<li><code>&lt;table&gt;</code></li>
+							</ul>
+					</li>
+					<li>Blending elements with specific style rules applied
+						<ul>
+							<li><code>transforms</code></li>
+							<li><code>transitions</code> </li>
+							<li><code>animations</code> </li>
+						</ul>
+					</li>
+				</ol>
+			</section>
+		</section>
+		<section>
+				<h2>Test cases description</h2>
+				<section>
+					<h3>Test cases for <code>mix-blend-mode</code></h3>
+					<p>
+						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.
+					</p>
+					<p>
+						<img id="test_outline" src="test_template.png" alt="Mix-blend-mode sample elements">
+					</p>
+					<p>The intended structure of the document is the following:</p>
+						<pre>
+&lt;body&gt;
+  &lt;div id="[P]"&gt;
+    &lt;div id="[IN-S]"&gt;&lt;/div&gt;
+    &lt;div id="[IN-P]"&gt;
+      &lt;div id="[B]"&gt;
+        &lt;div id="[CB]"&gt;&lt;/div&gt;
+      &lt;/div&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/body&gt;
+						</pre>
+					<p> Unless otherwise stated, test cases assume the following properties for the elements: <br>
+						<ul>
+						<li> default value for the <code>background-color</code> of the <code>body</code></li>
+						<li> <code>background-color</code> set to a fully opaque color for all the other elements </li>
+						</ul>
+					</p>
+					<p>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.</p>
+					<p>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.
+					</p></p>
+					<section>
+						<h4>An element with <code>mix-blend-mode</code> other than normal creates a stacking context</h4>
+						<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#mix-blend-mode" >spec</a>: <q>Applying a blendmode other than â€˜normalâ€™ to the element must establish a new stacking context [CSS21].</q></p>
+						<table>
+							<tr>
+								<th>Test name</th>
+								<th>Elements and styles</th>
+								<th>Expected result</th>
+							</tr>
+							<tr>
+								<td>Simple <code>&lt;div&gt;</td>
+								<td>1 element required: <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal
+								 </td>
+								<td>The element [B] creates a stacking context</td>
+							</tr>
+						</table>
+					</section>
+					<section>
+						<h4>An element with <code>mix-blend-mode</code> blends with the content within the current stacking context</h4>
+						<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#csscompositingrules_CSS">spec</a>: <q>An element that has blending applied, must blend with all the underlying content of the stacking context [CSS21] that that element belongs to.</q> </p>
+						<table>
+							<tr>
+								<th>Test name</th>
+								<th>Elements and styles</th>
+								<th>Expected result</th>
+							</tr>
+							<tr>
+								<td>Blending simple elements </td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and  <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal
+								</td>
+								<td>The color of the parent element [P] mixes with the color of the child element [B].</td>
+							</tr>
+							<tr>
+								<td>Blending <code>&lt;video&gt;</code></td>
+								<td>2 elements required: <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Sibling of the element [B]">[IN-S]</a> <br>
+									[B] - <code>&lt;video&gt;</code> element with <code>mix-blend-mode</code> other than normal <br>
+									[IN-S] - sibling(of the element [B]) visually overlaping the <code>&lt;video&gt;</code> element <br>
+									[IN-S] has some text inside
+							</td>
+								<td>The content of the <code>video</code> element [B] mixes with the colors of the sibling element and the text from [IN-S].</td>
+							</tr>
+							<tr>
+								<td>Blending with a sibling</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Sibling of the element [B]">[IN-S]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									[IN-S] - sibling of the element [B] <br>
+									The [IN-S] element visually overlaps the [B] element
+								</td>
+								<td>The colors of the parent element [P] and the sibling element [IN-S] mixes with the color of the blended element [B].</td>
+							</tr>
+							<tr>
+								<td>Blending with two levels of ascendants</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="child of the element [P]">[IN-P]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									[IN-P] - Intermediate child element between the parent [P] and the child [B]
+								</td>
+								<td>The colors of the parent element [P] and the child element [IN-P] mixes with the color of the blended element [B].</td>
+							</tr>
+						</table>
+					</section>
+					<section>
+						<h4>An element with <code>mix-blend-mode</code> doesn't blend with anything outside the current stacking context</h4>
+						<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#csscompositingrules_CSS">spec</a>: <q> An element that has blending applied, must blend with all the underlying content of the stacking context [CSS21] that that element belongs to.</q></p>
+						<table>
+							<tr>
+								<th>Test name</th>
+								<th>Elements and styles</th>
+								<th>Expected result</th>
+							</tr>
+							<tr>
+								<td>Blending child overflows the parent</td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									The blending element [B] has content that lies outside the parent element. <br>
+									Set the <code>background-color</code> of the <code>body</code> to a value other than default</td>
+								<td>The color of the parent element mixes with the color of the child element. <br>
+									 The area of the child element outside of the parent element doesn't mix with the color of the <code>body</code></td>
+							</tr>
+							<tr>
+								<td>Parent with transparent pixels</td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									The element has some text inside and default value for <code>background-color</code> <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									The <code>background-color</code> of the <code>body</code> has a value other than default</td>
+								<td>The color of the text from the parent element [P] mixes with the color of the child element [B]. <br>
+								No blending between the color of the <code>body</code> and the color of the blending element [B].
+								 </td>
+							</tr>
+							<tr>
+								<td>Parent with <code>border-radius</code></td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+										[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+										[P] has <code>border-radius</code> specified (e.g.50%). <br>
+										[B] - element with <code>mix-blend-mode</code> other than normal <br>
+										[B] has content that lies outside the parent element, over a rounded corner. <br>
+										The <code>background-color</code> of the <code>body</code> has a value other than default. </td>
+								<td>The color of the parent element mixes with the color of the child element. <br>
+									 The area of the child element which draws over the rounded corner doesn't mix with the color of the <code>body</code></td>
+							</tr>
+						</table>
+					</section>
+					<section>
+						<h4>An element with <code>mix-blend-mode</code> other than normal must cause a group to be isolated</h4>
+						<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#isolation" >spec</a>: <q>operations that cause the creation of stacking context [CSS21] must cause a group to be isolated.</q> </p>
+						<table>
+							<tr>
+								<th>Test name</th>
+								<th>Elements and styles</th>
+								<th>Expected result</th>
+							</tr>
+							<tr>
+								<td>Child of the blended element has opacity</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Child of the lement [B]">[CB]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									[CB] - child of the element [B] with <code>opacity</code> less than one. </td>
+								<td>The group created by the two child elements([B] and [CB]) is blended with the parent element [P]. <br>
+								No blending between [B] and [CB]</td>
+							</tr>
+							<tr>
+								<td>Overflowed child of the blended element</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Child of the lement [B]">[CB]</a> <br>
+										[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+										[B] - element with <code>mix-blend-mode</code> other than normal <br>
+										[CB] - child of the element [B] with content that lies outside the parent element [B].
+								</td>
+								<td>The group created by the two child elements([B] and [CB]) is blended with the parent element [P]. <br>
+								No blending between [B] and [CB]. There is only one color for the entire element [CB] </td>
+							</tr>
+							<tr>
+								<td>Blended element with transparent pixels</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Child of the lement [B]">[CB]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal and transparent <code>background-color</code> <br>
+									[CB] - child of the element [B]
+								</td>
+								<td>The group created by the two child elements([B] and [CB]) is blended with the parent element [P]. <br>
+								No blending between [B] and [CB]. </td>
+							</tr>
+						</table>
+					</section>
+					<section>
+						<h4>An element with <code>mix-blend-mode</code> must work properly with css transforms</h4>
+						<table>
+							<tr>
+								<th>Test name</th>
+								<th>Elements and styles</th>
+								<th>Expected result</th>
+							</tr>
+							<tr>
+								<td>Parent with 3D transform</td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and  <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with <code>3D transform</code> <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal
+								<td>The color of the parent element [P] mixes with the color of the child element [B] <br>
+									The element (and the content) of the element [P] is properly transformed
+								</td>
+							</tr>
+							<tr>
+								<td>Blended element with 3D transform</td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Child of the lement [B]">[CB]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal and <code>3D transform</code> <br>
+									[CB] - child of the element [B] </td>
+								<td> The color of the parent element [P] mixes with the color of the child element [B] <br>
+									The element (and the content) of the element [P] is properly transformed </td>
+							</tr>
+							<tr>
+								<td>Both parent and blended element with 3D transform</td>
+								<td> 2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and  <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with <code>3D transform</code> <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal and <code>3D transform</code>
+								</td>
+								<td>The color of the parent element [P] mixes with the color of the child element [B] <br>
+									The elements (and the content) of the elements [P]  and [B] are properly transformed</td>
+							</tr>
+							<tr>
+								<td>Blended element with transform and preserve-3d</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Child of the lement [B]">[CB]</a> <br>
+										[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+										[B] - element with <code>mix-blend-mode</code> other than normal and transform with <code>transform-style:preserve-3d</code> <br>
+										[CB] - child of the element [B]. It has 3D transform property</td>
+								<td> The child element [CB] will NOT preserve its 3D position. <br>
+								<code>mix-blend-mode</code> override the behavior of <code>transform-style:preserve-3d</code>:
+								creates a flattened representation of the descendant elements <br>
+								The color of the group created by the child elements([B] and [CB]) will blend with the color of the parent element [P] </td>
+							</tr>
+							<tr>
+								<td>Blended element with transform and perspective</td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+										[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+										[B] - element with <code>mix-blend-mode</code> other than normal and transform with <code>perspective</code> set to positive length </td>
+								<td>The colors of the parent and the child are mixed ([P] and [B]) <br>
+									The element (and the content) of the element [B] is properly transformed
+								</td>
+							</tr>
+							<tr>
+								<td>Sibling with 3D transform between the parent and the blended element</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Sibling of the element [B]">[IN-S]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									[IN-S] - Sibling(of the element [B]) with <code>3D transform</code> between the parent [P] and the child [B]
+									 </td>
+								<td>The colors of the parent element [P] and the transformed sibling element [IN-S] mixes with the color of the blended element [B].<br>
+								The element (and the content) of the element [IN-S] is properly transformed
+								</td>
+							</tr>
+							<tr>
+								<td>Parent with 3D transform and transition</td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and  <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with <code>3D transform</code> and transition <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal
+								<td>The color of the parent element [P] mixes with the color of the child element [B] <br>
+									The element (and the content) of the element [P] is properly transformed
+								</td>
+							</tr>
+							<tr>
+								<td>Sibling with 3D transform(and transition) between the parent and the blended element</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Sibling of the element [B]">[IN-S]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal <br>
+									[IN-S] - sibling(of the element [B]) with <code>3D transform</code> and transition between the parent [P] and the child [B]
+									 </td>
+								<td>The colors of the parent element [P] and the transformed sibling element [IN-S] mixes with the color of the blended element [B].<br>
+								The element (and the content) of the element [IN-S] is properly transformed
+								</td>
+							</tr>
+						</table>
+					</section>
+					<section>
+						<h4>An element with <code>mix-blend-mode</code> must work properly with elements with <code>overflow</code> property</h4>
+						<table>
+							<tr>
+								<td>Parent element with <code>overflow:scroll</code> </td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[P] has <code>overflow:scroll</code> <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal tat overflows the parents [P] dimensions so that it creates scrolling for the parent
+								<td>The color of the parent element [P] mixes with the color of the child element [B]. <br>
+									The scrolling mechanism is not affected.
+								</td>
+							</tr>
+							<tr>
+								<td>Blended element with <code>overflow:scroll</code></td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal, <code>overflow:scroll</code> and a child element that creates overflow for [B]</td>
+								<td>The color of the parent element [P] mixes with the color of the child element [B] <br>
+									The scrolling mechanism is not affected.
+								</td>
+							</tr>
+							<tr>
+								<td>Parent element with <code>overflow:scroll</code> and blended with <code>position:fixed</code> </td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[P] has <code>overflow:scroll</code> <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal, <code>position:fixed</code> and should overflow the parents [P] dimensions so that it creates scrolling for the parent</td>
+								<td>The color of the parent element [P] mixes with the color of the child element [B] <br>
+									The blending happens when scrolling the content of the parent element [P] too. <br>
+									The scrolling mechanism is not affected.
+								</td>
+							</tr>
+							<tr>
+								<td>Parent with <code>overflow:hidden</code> and <code>border-radius</code></td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[P] has <code>overflow:hidden</code> and <code>border-radius</code> specified (e.g.50%) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal with content that lies outside the parent element, over a rounded corner <br>
+									Set the <code>background-color</code> of the <code>body</code> to a value other than default.</td>
+								<td>The color of the parent element mixes with the color of the child element. <br>
+									The area of the child element which draws over the rounded corner is properly cut </td>
+							</tr>
+							<tr>
+								<td>Blended element with <code>overflow:hidden</code> and <code>border-radius</code></td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Child of the lement [B]">[CB]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal, <code>overflow:hidden</code> and <code>border-radius</code> specified (e.g.50%). <br>
+									[CB] - child of the element [B], with content that lies outside the parent element, over a rounded corner. <br> </td>
+								<td>The group created by the two child elements([B] and [CB]) is blended with the parent element [P]. <br>
+									No blending between [B] and [CB]. <br>
+									[CB] is properly clipped so no overflow is visible.</td>
+							</tr>
+							<tr>
+								<td>Intermediate child with <code>overflow:hidden</code> and <code>border-radius</code> between the parent and the blended element</td>
+								<td>3 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>, <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="child of the element [P]">[IN-P]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal that overflows the parents [IN-P] dimensions
+									[IN-P] - child(of the element [P]) with <code>overflow:hidden</code> and <code>border-radius</code> specified (e.g.50%)
+									 </td>
+								<td>The colors of the parent element [P] and the child element [IN-P] mixes with the color of the blended element [B]. <br>
+									[B] is is properly clipped so no overflow is visible
+								</td>
+							</tr>
+						</table>
+					</section>
+				<section>
+					<h4>Other test cases</h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Blended element with <code>border-image</code> </td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - element with <code>mix-blend-mode</code> other than normal and <code>border-image</code> specified as a png file
+							</td>
+							<td>The color of the parent element [P] mixes with the color of the child element. <br>
+								The color of the <code>border-image</code> mixes with the color of the parent element [P].
+							</td>
+						</tr>
+						<tr>
+							<td>Blending with <code>&lt;canvas&gt;</code> </td>
+							<td>2 elements required: <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Sibling of the element [B]">[IN-S]</a> <br>
+								[B] - <code>&lt;canvas&gt;</code> element with <code>mix-blend-mode</code> other than normal <br>
+								[IN-S] - Sibling of the <code>&lt;canvas&gt;</code> element with some text <br>
+								The [IN-S] element overlaps the <code>&lt;canvas&gt;</code> element
+							</td>
+							<td>The content of the <code>&lt;canvas&gt;</code> element mixes with the color of the sibling element and the text [IN-S].</td>
+						</tr>
+						<tr>
+							<td>Blended <code>&lt;canvas&gt;</code></td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - Child <code>&lt;canvas&gt;</code> element with <code>mix-blend-mode</code> other than normal
+							</td>
+							<td>The color of the <code>&lt;canvas&gt;</code> element [B] mixes with the color of the parent element [P] .</td>
+						</tr>
+						<tr>
+							<td>Blended <code>&lt;video&gt;</code></td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - <code>&lt;video&gt;</code> element with <code>mix-blend-mode</code> other than normal
+							</td>
+							<td>The color of the <code>&lt;video&gt;</code> element mixes with the color of the parent element [P] .</td>
+						</tr>
+						<tr>
+							<td>Blending with <code>&lt;iframe&gt;</code> </td>
+							<td>2 elements required: <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> and <a href="#test_outline" title="Sibling of the element [B]">[IN-S]</a> <br>
+									[B] - <code>&lt;iframe&gt;</code> element with <code>mix-blend-mode</code> other than normal <br>
+									[IN-S] - sibling(of the element [B]) with some text <br>
+									The [IN-S] element visually overlaps the <code>&lt;iframe&gt;</code> element
+							</td>
+							<td>The color of the <code>&lt;iframe&gt;</code> element mixes with the color of the sibling element and the text [IN-S].</td>
+						</tr>
+						<tr>
+							<td>Blended <code>&lt;iframe&gt;</code></td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - <code>&lt;iframe&gt;</code> element with <code>mix-blend-mode</code> other than normal
+							</td>
+							<td>The color of the <code>&lt;iframe&gt;</code> element [B] mixes with the color of the parent element [P]. </td>
+						</tr>
+						<tr>
+							<td>Blended element with <code>mask</code> property</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - element with <code>mix-blend-mode</code> other than normal and <code>mask</code> property specified to an SVG image (e.g. circle)</td>
+							<td>The colors of the parent and the masked child are mixed ([P] and [B])</td>
+						</tr>
+						<tr>
+							<td>Blended element with <code>clip-path</code> property </td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - element with <code>mix-blend-mode</code> other than normal and <code>clip-path</code> property specified to a basic shape (e.g. ellipse)</td>
+							<td>The colors of the parent and the clipped child are mixed ([P] and [B])</td>
+						</tr>
+						<tr>
+							<td>Blended element with <code>filter</code> property</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - element with <code>mix-blend-mode</code> other than normal and <code>filter</code> property value other than none </td>
+							<td>The filter is applied and the result is mixed with the parent element</td>
+						</tr>
+						<tr>
+							<td>Blended element with <code>transition</code></td>
+								<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+									[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+									[B] - element with <code>mix-blend-mode</code> other than normal and <code>transition-property</code> for <code>opacity</code> </td>
+							<td>The transition is applied and the result is mixed with the parent element</td>
+						</tr>
+							<tr>
+							<td>Blended element with <code>animation</code></td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - element with <code>mix-blend-mode</code> other than normal and <code>animation</code> specified</td>
+							<td>The animation is applied to the child element and the result is mixed with the parent element</td>
+						</tr>
+						<tr>
+							<td>Image element</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - <code>&lt;img&gt;</code> element (.jpeg or .gif image) with <code>mix-blend-mode</code> other than normal</td>
+							<td>The color of the <code>&lt;img&gt;</code> is mixed with the color of the <code>&lt;div&gt;</code>.</td>
+						</tr>
+						<tr>
+							<td>SVG element</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - SVG element with <code>mix-blend-mode</code> other than normal</td>
+							<td>The color of the SVG is mixed with the color of the <code>&lt;div&gt;</code>.</td>
+						</tr>
+						<tr>
+							<td>Paragraph element</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - paragraph element with <code>mix-blend-mode</code> other than normal</td>
+							<td>The color of the text from the paragraph element is mixed with the color of the <code>&lt;div&gt;</code></td>
+						</tr>
+						<tr>
+							<td>Paragraph element and background-image</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								 and  <code>background-image</code> <br>
+								[B] - Child <code>p</code> element with some text and <code>mix-blend-mode</code> other than normal</td>
+							<td>The color of the text from the <code>p</code> element is mixed with the background image of the <code>&lt;div&gt;</code>.</td>
+						</tr>
+						<tr>
+							<td>Set blending from JavaScript</td>
+							<td>2 elements required: <a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and <a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[B] - Child <code>&lt;div&gt;</code> element with no <code>mix-blend-mode</code> specified<br>
+								From JavaScript, set the <code>mix-blend-mode</code> property for the child <code>&lt;div&gt;</code> to a value other than normal</td>
+							<td>The colors of the <code>&lt;div&gt;</code> elements are mixed.</td>
+						</tr>
+					</table>
+				</section>
+			</section>
+			<section>
+				<h3>Test cases for SVG elements with <code>mix-blend-mode</code></h4>
+				<section>
+					<h4><code>mix-blend-mode</code> with simple SVG graphical elements</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#mix-blend-mode" >spec</a> : <q><code>mix-blend-mode</code> applies to svg, g, use, image, path, rect, circle, ellipse, line, polyline, polygon, text, tspan, and marker.</q></p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Circle with SVG background</td>
+							<td>Set a background color for the SVG.<br>
+								Create 16 <code>circle</code> elements and fill them with a solid color.
+								<br>Apply each <code>mix-blend-mode</code> on them.</td>
+							<td>The color of the <code>circle</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Ellipse with SVG background</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>ellipse</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> on it other than <code>normal</code>.</td>
+							<td>The color of the <code>ellipse</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Image with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create an <code>image</code> element and apply a <code>mix-blend-mode</code> other than <code>normal</code>.</td>
+							<td>The <code>image</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Line with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>line</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> on it other than <code>normal</code>.</td>
+							<td>The color of the <code>line</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Path with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>path</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> on it other than <code>normal</code>.</td>
+							<td>The color of the <code>path</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Polygon with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>polygon</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> on it other than <code>normal</code>.</td>
+							<td>The color of the <code>polygon</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Polyline with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>polyline</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> on it other than <code>normal</code>.</td>
+							<td>The color of the <code>polyline</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Rect with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>rect</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> on it other than <code>normal</code>.</td>
+							<td>The color of the <code>rect</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Text with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>text</code> element and apply a <code>mix-blend-mode</code> other than <code>normal</code>.</td>
+							<td>The text is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Text having tspan with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>text</code> element and a <code>tspan</code> inside it.
+								<br>Apply a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>tspan</code>.</td>
+							<td>The text is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Gradient with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>rect</code> element and fill it with a <code>gradient</code>.
+								<br>Apply a <code>mix-blend-mode</code> on it other than normal.</td>
+							<td>The gradient is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Pattern with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>rect</code> element and fill it with a <code>pattern</code>.
+								<br>Apply a <code>mix-blend-mode</code> on it other than normal.</td>
+							<td>The pattern is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Set blending on an element from JavaScript</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>rect</code> element and fill it with a solid color.
+								<br>Apply a <code>mix-blend-mode</code> (other than <code>normal</code>) on it from JavaScript.</td>
+							<td>The color of the <code>rect</code> is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Marker with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>line</code> element containing a marker.
+								<br>Apply a <code>mix-blend-mode</code> other than <code>normal</code> on the marker.</td>
+							<td>The marker color is mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>Metadata with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>metadata</code> element containing an embedded pdf.
+								<br>Apply a <code>mix-blend-mode</code> other than <code>normal</code> on the marker.</td>
+							<td>The metadata content is not mixed with the color of the background.</td>
+						</tr>
+						<tr>
+							<td>ForeignObject with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>foreignObject</code> element containing a simple xhtml file.
+								<br>Apply a <code>mix-blend-mode</code> other than <code>normal</code> on the marker.</td>
+							<td>The foreignObject content is not mixed with the color of the background.</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>mix-blend-mode</code> with SVG groups</h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Group of overlapping elements with SVG background</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>group</code> element containing two overlapping <code>rect</code> elements, each filled with a different solid color.
+								<br>Apply a <code>mix-blend-mode</code> other than <code>normal</code> on the group.</td>
+							<td>The <code>group</code> is mixed as a whole with the color of the background.</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>mix-blend-mode</code> with isolated groups</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#mix-blend-mode" >spec</a>:
+					<br><q>By default, every element must create a non-isolated group.<br>
+						However, certain operations in SVG will create isolated groups.<br>
+						If one of the following features is used, the group must become isolated:
+						<ul>
+						    <li>opacity</li>
+						    <li>filters</li>
+						    <li>3D transforms (2D transforms must NOT cause isolation)</li>
+						    <li>blending</li>
+						    <li>masking</li>
+						</ul>
+					</q>
+					</p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Blending two elements in an isolated group</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing two overlapping <code>rect</code> elements, each filled with a different solid color.<br>
+								Apply <code>opacity</code> less than 1 on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the second rect.</td>
+							<td>Only the intersection of the <code>rect</code> elements should mix.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with opacity</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply <code>opacity</code> less than 1 on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with filter</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>filter</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with 2D transform</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>transform</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with 3D transform</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply a 3d transform on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with a mask</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>mask</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with mix-blend-mode</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>mix-blend-mode</code> other than <code>normal</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4>Other test cases for SVG</h4>
+					<table>
+						<tr>
+							<td>Blend with element having opacity</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>rect</code> element filled with a different solid color.<br>
+								Apply <code>opacity</code> less than 1 and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with element having stroke</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>stroke</code> and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with element having stroke-opacity</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>stroke</code>, <code>stroke-opacity</code> less than 1 and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with element having stroke-dasharray</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>rect</code> element filled with a different solid color.<br>
+								Apply a <code>stroke-dasharray</code> and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with element having transform</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>image</code> element. Apply a <code>transform</code> (any combination of <code>translate</code>, <code>rotate</code>, <code>scale</code>, <code>skew</code>) and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>image</code>.</td>
+							<td>The <code>image</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with SVG having viewbox and preserveAspectRatio set</td>
+							<td>Set a background color for the SVG, as well as <code>viewbox</code> and <code>preserveAspectRatio</code>.<br>
+								Create a <code>rect</code> element filled with a different solid color and apply a <code>mix-blend-mode</code> other than <code>normal</code> on it.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with an element having color-profile set</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>image</code> element. Apply a <code>color-profile</code> (<code>sRGB</code>, for example) and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>image</code>.</td>
+							<td>The <code>image</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with an element having overflow</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>image</code> larger than the SVG.<br>
+								Apply <code>overflow</code> (<code>visible</code>, <code>hidden</code>, <code>scroll</code>) and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>image</code>.</td>
+							<td>The <code>image</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with an element having clip-path</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>image</code> element. Apply a <code>clip-path</code> and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>image</code>.</td>
+							<td>The <code>image</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with an element having a mask</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>image</code> element.<br>
+								Apply a <code>mask</code> and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>image</code>.</td>
+							<td>The <code>image</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with an element having a filter</td>
+							<td>Set a background color for the SVG.<br>
+								Create an <code>image</code> element.<br>
+								Apply a <code>filter</code> and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>image</code>.</td>
+							<td>The <code>image</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blend with an animated element</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>rect</code> element filled with a different solid color.<br>
+								Apply an <code>animateTransform</code> and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Set blending from an SVG script element</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>rect</code> element and fill it with a solid color.<br>
+								Apply a <code>mix-blend-mode</code> (other than <code>normal</code>) on it from an svg <code>script</code> element.</td>
+							<td>The <code>rect</code> will mix with the content behind it.</td>
+						</tr>
+					</table>
+				</section>
+			</section>
+			<section>
+				<h3>Test cases for <code>background-blend-mode</code></h3>
+				<section>
+					<h4>Blending between the background layers and the background color for an element with <code>background-blend-mode</code> </h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#background-blend-mode">spec</a>: <q>Each background layer must blend with the element's background layer that are below it and the element's background color.</q></p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Images with different formats</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+								Tests should be created for <code>&lt;image&gt;</code> with different formats such as PNG, JPEG or SVG
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code></td>
+						</tr>
+						<tr>
+							<td>Gradient and background color</td>
+							<td>
+								Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;gradient&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code></td>
+						</tr>
+						<tr>
+							<td>Image and gradient</td>
+							<td>
+								Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code> on top of a <code>&lt;gradient&gt;</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>&lt;image&gt;</code> is mixed with the content of the <code>&lt;gradient&gt;</code>
+							</td>
+						</tr>
+						<tr>
+							<td>Gradient and image</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to a <code>&lt;gradient&gt;</code> on top of an <code>&lt;image&gt;</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>&lt;image&gt;</code> is mixed with the content of the <code>&lt;gradient&gt;</code></td>
+						</tr>
+						<tr>
+							<td>Two gradients</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to a <code>&lt;gradient&gt;</code> on top of another <code>&lt;gradient&gt;</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul></td>
+							<td>The content of the two gradients is mixed</td>
+						</tr>
+						<tr>
+							<td>Two images</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code> on top of another <code>&lt;image&gt;</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul></td>
+							<td>The content of the two images is mixed</td>
+						</tr>
+						<tr>
+							<td>Image and background color with transparency</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code> with transparency(e.g. PNG images)</li>
+									<li><code>background-color</code> set to a transparent color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code></td>
+						</tr>
+						<tr>
+							<td>Cross-fade image and gradient</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to a <q>cross-fade()</q> image on top of a <code>&lt;gradient&gt;</code> </li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the cross-faded image is mixed with the content of the <code>&lt;gradient&gt;</code></td>
+						</tr>
+						<tr>
+							<td>SVG image and background color</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to a data URI for an SVG image </li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the image is mixed with the color of the background</td>
+						</tr>
+						<tr>
+							<td>Animated gif image and background color</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an animated gif image</li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the image is mixed with the color of the background</td>
+						</tr>
+						<tr>
+							<td>Set <code>background-blend-mode</code> from JavaScript</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to a <code>gradient</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li>no <code>background-blend-mode</code> explicitly specified</li>
+									From JavaScript, set the <code>background-blend-mode</code> property to a value other than normal.
+								</ul>
+							</td>
+							<td>The content of the gradient is mixed with the color of the background</td>
+						</tr>
+						<tr>
+							<td><code>background-blend-mode</code> on element with 3D transform</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+									<li><code>transform</code> set to a 3D function like rotateX, rotateY or translateZ</li>
+								</ul>
+							</td>
+							<td>The content of the image is mixed with the color of the background</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4>Background layers do not blend with content outside the background (or behind the element)</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#background-blend-mode">spec</a>: <q>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.</q>
+					</p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>One background layer</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The <code>background-image</code> is not mixed with anything outside the element</td>
+						</tr>
+						<tr>
+							<td>Two elements</td>
+							<td>2 elements required: a parent element with a child. <br>
+								Each one with the following properties:
+								<ul>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							<td>No blending between the background colors of the two elements</td>
+						</tr>
+						<tr>
+							<td>Parent and child with <code>background-blend-mode</code></td>
+							<td>2 elements required: a parent element with a child <br>
+								Parent properties: <br>
+								<ul>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+								Child properties: <br>
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							<td>The content of the image from the child element does not mixes with the background color from the parent element</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4> <code>background-blend-mode</code> list values apply to the corresponding background layer</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#background-blend-mode">spec</a>: <q>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.</q>
+					</p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Different blend modes applied between layers</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image-list&gt;</code> containing three images: (e.g. I1, I2 and I3 ) </li>
+									<li><code>background-blend-mode</code> set to different <code>blendmode</code> for every image: (e.g. multiply, difference, screen) </li>
+								</ul></td>
+							<td>The content of the three images is correctly mixed <br>
+							(multiply for I1, difference for I2 and screen for I3)
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> list values are repeated if the list is shorter than the background layer list</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#background-blend-mode">spec</a>: <q>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.</q>
+					</p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Blend mode list repeat</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image-list&gt;</code> containing three images</li>
+									<li><code>background-blend-mode</code> set to two different <code>blendmode</code> values</li>
+								</ul></td>
+							<td>The unspecified blend modes should be obtained by repeating the blend mode list from the beginning</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4>The default <code>background-blend-mode</code> value for the <code>background</code> shorthand is 'normal' </h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#background-blend-mode">spec</a>: <q>If the â€˜backgroundâ€™ [CSS3BG] shorthand is used, the â€˜background-blend-modeâ€™ property for that element must be reset to its initial value.</q>
+					</p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Default blend mode for 'background' shorthand</td>
+							<td>Element with
+								<ul>
+									<li><code>background</code> property set to an image and a color</li>
+									<li>No value explicitly set for <code>background-blend-mode</code> </li>
+								</ul></td>
+							<td> The computed value of <code>background-blend-mode</code> is 'normal'
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> for an element with <code>background-position</code></h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td><code>background-position</code> percentage</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-position</code> specified in percentage, such as 50% 50%</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The <code>background-image</code> is correctly positioned
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> for an element with <code>background-size</code></h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Background size defined in pixels</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-size</code> specified in pixels</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The <code>background-image</code> has the correct size
+							</td>
+						</tr>
+						<tr>
+							<td>Background size defined in percentage (second phase)</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-size</code> specified in percentage</li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The <code>background-image</code> has the correct size
+							</td>
+						</tr>
+						<tr>
+							<td>Background size cover</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-size</code> set to <code>cover</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The <code>background-image</code> has the correct size
+							</td>
+						</tr>
+						<tr>
+							<td>Background size contain</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-size</code> set to <code>contain</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The <code>background-image</code> has the correct size
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> for an element with <code>background-repeat</code></h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td><code>background-repeat</code> set to no-repeat</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-repeat</code> set to <code>no-repeat</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The <code>background-image</code> is not repeated
+							</td>
+						</tr>
+						<tr>
+							<td><code>background-repeat</code> set to space</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-repeat</code> set to <code>space</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							</td>
+						</tr>
+						<tr>
+							<td><code>background-repeat</code> set to round</td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-repeat</code> set to <code>round</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> for an element with <code>background-clip</code></h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td><code>background-clip</code> set to <code>padding-box</code></td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-clip</code> set to <code>padding-box</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							No background is drawn below the border (background extends to the outside edge of the padding)
+							</td>
+						</tr>
+						<tr>
+							<td><code>background-clip</code> set to <code>content-box</code></td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-clip</code> set to <code>content-box</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The background is painted within (clipped to) the content box
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> for an element with <code>background-origin</code></h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td><code>background-origin</code> set to <code>border-box</code></td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-origin</code> set to <code>border-box</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The background extends to the outside edge of the border (but underneath the border in z-ordering)
+							</td>
+						</tr>
+						<tr>
+							<td><code>background-origin</code> set to <code>content-box</code></td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-origin</code> set to <code>content-box</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The background is painted within (clipped to) the content box
+							</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4><code>background-blend-mode</code> for an element with <code>background-attachement</code></h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td><code>background-attachment</code> set to <code>fixed</code></td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to an <code>&lt;image&gt;</code></li>
+									<li><code>background-color</code> set to a fully opaque color</li>
+									<li><code>background-attachment</code> set to <code>fixed</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The content of the <code>background-image</code> is mixed with the color of the <code>background-color</code> <br>
+							The background image will not scroll with its containing element, instead remaining stationary within the viewport
+							</td>
+						</tr>
+						<tr>
+							<td>2 background images with <code>background-attachment</code> set to <code>fixed, scroll</code></td>
+							<td>Element with
+								<ul>
+									<li><code>background-image</code> set to 2 <code>&lt;image&gt;</code>(s)</li>
+									<li><code>background-attachment</code> set to <code>fixed, scroll</code></li>
+									<li><code>background-blend-mode</code> other than normal</li>
+								</ul>
+							</td>
+							<td>The background images will be mixed when they overlap while scrolling
+							</td>
+						</tr>
+					</table>
+				</section>
+		</section>
+			<section>
+				<h3>Test cases for <code>isolation</code></h3>
+				<section>
+					<h4>An element with <code>isolation:isolate</code> creates a stacking context</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#csscompositingrules_CSS">spec</a>: <q>For CSS, setting â€˜isolationâ€™ to â€˜isolateâ€™ will turn the element into a stacking context [CSS21].</q></p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Isolation isolate</td>
+							<td>Have an element with <code>isolation</code> set to <code>isolate</code></td>
+							<td>The element creates a stacking context.</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4>An element with <code>isolation:isolate</code> creates an isolated group for blended children</h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Isolation of blended child which overflows</td>
+							<td>3 elements required:
+								<a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>,
+								<a href="#test_outline" title="child of the element [P]">[IN-P]</a> and
+								<a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>) <br>
+								[IN-P] - Intermediate child element between the parent [P] and the child [B]<br>
+								This element has <code>isolation:isolate</code> set.<br>
+								[B] - element with <code>mix-blend-mode</code> other than <code>normal</code> <br>
+								The blending element [B] has content that lies outside the parent element. <br>
+							</td>
+							<td>
+								The color of the child element [B] mixes with the color of the intermediate element [IN-P], where they overlap.<br>
+								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 <code>body</code>.
+							</td>
+						</tr>
+						<tr>
+							<td>Isolation on intermediate element with transparent pixels</td>
+							<td>3 elements required:
+								<a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>,
+								<a href="#test_outline" title="child of the element [P]">[IN-P]</a> and
+								<a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>); the element <code>background-color</code> is other than <code>transparent</code><br>
+								[IN-P] - Intermediate child element between the parent [P] and the child [B]<br>
+								The intermediate element has text content, default value for <code>background-color</code> and <code>isolation:isolate</code> set<br>
+								[B] - element with <code>mix-blend-mode</code> other than <code>normal</d <br>
+							<td>
+								The color of the child element [B] mixes with the color of the intermediate element [IN-P], where they overlap.<br>
+								There is no blending between the color of the parent element [P] and the color of the blended element [B].
+							</td>
+						</tr>
+						<tr>
+							<td>Isolate inside a stacking context created by a 3d transform</td>
+							<td>
+								3 elements required:
+								<a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a>,
+								<a href="#test_outline" title="child of the element [P]">[IN-P]</a> and
+								<a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a <code>3D transform</code> applied<br>
+								[IN-P] - Intermediate child element between the parent [P] and the child [B]<br>
+								The intermediate element has <code>isolation:isolate</code> set<br>
+								[B] - element with <code>mix-blend-mode</code> other than <code>normal</code><br>
+							</td>
+							<td>
+								The color of the child element [B] mixes with the color of the intermediate element [IN-P], where they overlap.<br>
+								There is no blending between the color of the parent element [P] and the color of the blended element [B].
+							 </td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4>An element with <code>isolation:auto</code> set does not change the elements existing stacking context behavior</h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Isolation auto</td>
+							<td>Have an element with <code>isolation</code> explicitly set to <code>auto</code>, and no other style that would create a stacking context</td>
+							<td>The element does not create a stacking context - the computed value of its <code>z-index</code> is value <code>auto</code></td>
+						</tr>
+						<tr>
+							<td>Stacking context not affected by isolation</td>
+							<td>2 elements required:
+								<a href="#test_outline" title="parent element with a property that creates stacking context">[P]</a> and
+								<a href="#test_outline" title="Element with mix-blend-mode property other than normal">[B]</a> <br>
+								[P] - parent element with a property that creates a stacking context (e.g. <code>position:fixed</code>); This element has <code>isolation</code> explicitly set to <code>auto</code> <br>
+								[B] - element with <code>mix-blend-mode</code> other than <code>normal</code> <br>
+								The blending element [B] has content that lies outside the parent element. <br>
+								Set the <code>background-color</code> of the <code>body</code> to a value other than default
+							</td>
+							<td>The color of the parent element mixes with the color of the child element. <br>
+								The area of the child element outside of the parent element doesn't mix with the color of the <code>body</code>.<br>
+								In other words, setting the <code>isolation</code> to <code>auto</code> does not affect the creation of a stacking context by other properties.
+							</td>
+						</tr>
+					</table>
+				</section>
+			</section>
+			<section>
+				<h4>Test cases for <code>isolation</code> in SVG</h4>
+				<section>
+					<h4>In SVG, an element with <code>isolation:isolate</code> creates an isolated group for blended children</h4>
+					<p>Refers to the following assertion in the <a href="https://drafts.fxtf.org/compositing-1/#isolation">spec</a>: <q>In SVG, this defines whether an element is isolated or not.</q></p>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Blending in an isolated group</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply <code>isolation:isolate</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending two elements in an isolated group</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing two overlapping <code>rect</code> elements, each filled with a different solid color.<br>
+								Apply <code>isolation:isolate</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the second rect.</td>
+							<td>Only the intersection of the <code>rect</code> elements should mix.</td>
+						</tr>
+						<tr>
+							<td>Blending in an isolated group with 2D transform</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply <code>isolation:isolate</code> and 2D transform on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Set isolation on an element from JavaScript</td>
+							<td>Set a background color for the SVG.
+								<br>Create a <code>rect</code> element and fill it with a solid color and a <code>mix-blend-mode</code> other than <code>normal</code>.
+								<br>Apply <code>isolation:isolate</code> on it from JavaScript.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+					</table>
+				</section>
+				<section>
+					<h4>In SVG, an element with <code>isolation:auto</code> set does not change the rendering behaviour</h4>
+					<table>
+						<tr>
+							<th>Test name</th>
+							<th>Elements and styles</th>
+							<th>Expected result</th>
+						</tr>
+						<tr>
+							<td>Blending a group with <code>isolation:auto</code></td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply <code>isolation:auto</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The element will mix with the content behind it.</td>
+						</tr>
+						<tr>
+							<td>Blending in a group with opacity</td>
+							<td>Set a background color for the SVG.<br>
+								Create a <code>group</code> element containing a <code>rect</code> element filled with a different solid color.<br>
+								Apply <code>opacity</code> less than 1 and <code>isolation:auto</code> on the group and a <code>mix-blend-mode</code> other than <code>normal</code> on the <code>rect</code>.</td>
+							<td>The <code>rect</code> will not mix with the content behind it.</td>
+						</tr>
+					</table>
+				</section>
+			</section>
+	</body>
+</html>
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 @@
+<!DOCTYPE html>
+<title>Canvas test: toBlob.png</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<canvas id="c"></canvas>
+<script>
+async_test(function() {
+    on_event(window, "load", this.step_func(function() {
+        var canvas = document.getElementById('c');
+        var ctx = canvas.getContext('2d');
+        canvas.toBlob(this.step_func_done(function(data) {
+            assert_equals(data.type, "image/png");
+        }), 'image/png');
+    }));
+}, "toBlob with image/png returns a PNG Blob");
+</script>
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 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Test: will-change: position turns an element in an abspos containing block.</title>
+<link rel="author" title="Emilio Cobos Ã�lvarez" href="mailto:emilio@crisal.io">
+<link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu">
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1498873">
+<link rel="help" href="https://drafts.csswg.org/css-will-change/#will-change">
+<link rel="match" href="will-change-abspos-cb-001-ref.html">
+<style>
+  .container {
+    border: 1px solid green;
+    width: 100px;
+    height: 100px;
+    margin-top: 100px;
+    display: flex;
+    will-change: position;
+  }
+  .abspos {
+    position: absolute;
+    top: 0;
+    left: 0;
+    background: orange;
+    height: 20px;
+    width: 20px;
+  }
+</style>
+<div class="container">
+  <div class="abspos"></div>
+</div>

From 0db23a35d8424dc2b32a55a99bdcf8bd34d5d0f5 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <geoffers@gmail.com>
Date: Fri, 15 May 2020 04:39:41 +0100
Subject: [PATCH 067/105] Use dict on Py >= 3.7 for attributes now it is
 ordered

---
 html5lib/html5parser.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 6ba7b080..06411212 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -2,7 +2,9 @@
 from six import with_metaclass, viewkeys
 
 import types
+
 from collections import OrderedDict
+from sys import version_info
 
 from . import _inputstream
 from . import _tokenizer
@@ -24,6 +26,12 @@
 )
 
 
+if version_info >= (3, 7):
+    attributeMap = dict
+else:
+    attributeMap = OrderedDict
+
+
 def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
     """Parse an HTML document as a string or file-like object into a tree
 
@@ -329,10 +337,11 @@ def normalizeToken(self, token):
         # HTML5 specific normalizations to the token stream
         if token["type"] == tokenTypes["StartTag"]:
             raw = token["data"]
-            token["data"] = OrderedDict(raw)
-            if len(raw) > len(token["data"]):
+            data = attributeMap(raw)
+            if len(raw) > len(data):
                 # we had some duplicated attribute, fix so first wins
-                token["data"].update(raw[::-1])
+                data.update(raw[::-1])
+            token["data"] = data
 
         return token
 
@@ -2770,8 +2779,8 @@ def processEndTag(self, token):
 def adjust_attributes(token, 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())
+        token['data'] = attributeMap((replacements.get(k, k), v)
+                                     for k, v in token['data'].items())
 
 
 def impliedTagToken(name, type="EndTag", attributes=None,

From f1b28b0eab3cbe3e8a73541aeb3541e31e401c8f Mon Sep 17 00:00:00 2001
From: Sam Sneddon <geoffers@gmail.com>
Date: Fri, 15 May 2020 13:59:53 +0100
Subject: [PATCH 068/105] Avoid allocating bytes slice in encoding pre-parse

---
 html5lib/_inputstream.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index c0cdccfb..2fcee31c 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -658,9 +658,7 @@ def matchBytes(self, bytes):
         """Look for a sequence of bytes at the start of a string. If the bytes
         are found return True and advance the position to the byte after the
         match. Otherwise return False and leave the position alone"""
-        p = self.position
-        data = self[p:p + len(bytes)]
-        rv = data.startswith(bytes)
+        rv = self.startswith(bytes, self.position)
         if rv:
             self.position += len(bytes)
         return rv

From 9d1a0fd9ef522e4d68558183fabab2100880733b Mon Sep 17 00:00:00 2001
From: Sam Sneddon <geoffers@gmail.com>
Date: Fri, 15 May 2020 14:15:25 +0100
Subject: [PATCH 069/105] Shortcut the entire meta encoding pre-parse when
 possible

---
 html5lib/_inputstream.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 2fcee31c..0207dd21 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -682,6 +682,9 @@ def __init__(self, data):
         self.encoding = None
 
     def getEncoding(self):
+        if b"<meta" not in self.data:
+            return None
+
         methodDispatch = (
             (b"<!--", self.handleComment),
             (b"<meta", self.handleMeta),

From b075e514f0534d2b830fb7ad134402a60c871e41 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Fri, 15 May 2020 21:40:49 +0100
Subject: [PATCH 070/105] Only initialise the method dispatcher once

This has a _significant_ effect on parser creation time
---
 html5lib/_utils.py      |  38 ++-
 html5lib/html5parser.py | 698 +++++++++++++++++++++-------------------
 2 files changed, 396 insertions(+), 340 deletions(-)

diff --git a/html5lib/_utils.py b/html5lib/_utils.py
index 2fcfb802..179d7015 100644
--- a/html5lib/_utils.py
+++ b/html5lib/_utils.py
@@ -2,6 +2,11 @@
 
 from types import ModuleType
 
+try:
+    from collections.abc import Mapping
+except ImportError:
+    from collections import Mapping
+
 from six import text_type
 
 try:
@@ -47,9 +52,6 @@ class MethodDispatcher(dict):
     """
 
     def __init__(self, items=()):
-        # Using _dictEntries instead of directly assigning to self is about
-        # twice as fast. Please do careful performance testing before changing
-        # anything here.
         _dictEntries = []
         for name, value in items:
             if isinstance(name, (list, tuple, frozenset, set)):
@@ -64,6 +66,36 @@ def __init__(self, items=()):
     def __getitem__(self, key):
         return dict.get(self, key, self.default)
 
+    def __get__(self, instance, owner=None):
+        return BoundMethodDispatcher(instance, self)
+
+
+class BoundMethodDispatcher(Mapping):
+    """Wraps a MethodDispatcher, binding its return values to `instance`"""
+    def __init__(self, instance, dispatcher):
+        self.instance = instance
+        self.dispatcher = dispatcher
+
+    def __getitem__(self, key):
+        # see https://docs.python.org/3/reference/datamodel.html#object.__get__
+        # on a function, __get__ is used to bind a function to an instance as a bound method
+        return self.dispatcher[key].__get__(self.instance)
+
+    def get(self, key, default):
+        if key in self.dispatcher:
+            return self[key]
+        else:
+            return default
+
+    def __iter__(self):
+        return iter(self.dispatcher)
+
+    def __len__(self):
+        return len(self.dispatcher)
+
+    def __contains__(self, key):
+        return key in self.dispatcher
+
 
 # Some utility functions to deal with weirdness around UCS2 vs UCS4
 # python builds
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 06411212..fe155aec 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -451,10 +451,13 @@ def getMetaclass(use_metaclass, metaclass_func):
     class Phase(with_metaclass(getMetaclass(debug, log))):
         """Base class for helper object that implements each phase of processing
         """
+        __slots__ = ("parser", "tree", "__startTagCache", "__endTagCache")
 
         def __init__(self, parser, tree):
             self.parser = parser
             self.tree = tree
+            self.__startTagCache = {}
+            self.__endTagCache = {}
 
         def processEOF(self):
             raise NotImplementedError
@@ -474,7 +477,21 @@ def processSpaceCharacters(self, token):
             self.tree.insertText(token["data"])
 
         def processStartTag(self, token):
-            return self.startTagHandler[token["name"]](token)
+            # Note the caching is done here rather than BoundMethodDispatcher as doing it there
+            # requires a circular reference to the Phase, and this ends up with a significant
+            # (CPython 2.7, 3.8) GC cost when parsing many short inputs
+            name = token["name"]
+            # In Py2, using `in` is quicker in general than try/except KeyError
+            # In Py3, `in` is quicker when there are few cache hits (typically short inputs)
+            if name in self.__startTagCache:
+                func = self.__startTagCache[name]
+            else:
+                func = self.__startTagCache[name] = self.startTagHandler[name]
+                # bound the cache size in case we get loads of unknown tags
+                while len(self.__startTagCache) > len(self.startTagHandler) * 1.1:
+                    # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
+                    self.__startTagCache.pop(next(iter(self.__startTagCache)))
+            return func(token)
 
         def startTagHtml(self, token):
             if not self.parser.firstStartTag and token["name"] == "html":
@@ -487,9 +504,25 @@ def startTagHtml(self, token):
             self.parser.firstStartTag = False
 
         def processEndTag(self, token):
-            return self.endTagHandler[token["name"]](token)
+            # Note the caching is done here rather than BoundMethodDispatcher as doing it there
+            # requires a circular reference to the Phase, and this ends up with a significant
+            # (CPython 2.7, 3.8) GC cost when parsing many short inputs
+            name = token["name"]
+            # In Py2, using `in` is quicker in general than try/except KeyError
+            # In Py3, `in` is quicker when there are few cache hits (typically short inputs)
+            if name in self.__endTagCache:
+                func = self.__endTagCache[name]
+            else:
+                func = self.__endTagCache[name] = self.endTagHandler[name]
+                # bound the cache size in case we get loads of unknown tags
+                while len(self.__endTagCache) > len(self.endTagHandler) * 1.1:
+                    # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
+                    self.__endTagCache.pop(next(iter(self.__endTagCache)))
+            return func(token)
 
     class InitialPhase(Phase):
+        __slots__ = tuple()
+
         def processSpaceCharacters(self, token):
             pass
 
@@ -618,6 +651,8 @@ def processEOF(self):
             return True
 
     class BeforeHtmlPhase(Phase):
+        __slots__ = tuple()
+
         # helper methods
         def insertHtmlElement(self):
             self.tree.insertRoot(impliedTagToken("html", "StartTag"))
@@ -653,19 +688,7 @@ def processEndTag(self, token):
                 return token
 
     class BeforeHeadPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("head", self.startTagHead)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                (("head", "body", "html", "br"), self.endTagImplyHead)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         def processEOF(self):
             self.startTagHead(impliedTagToken("head", "StartTag"))
@@ -698,28 +721,19 @@ def endTagOther(self, token):
             self.parser.parseError("end-tag-after-implied-root",
                                    {"name": token["name"]})
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml),
+            ("head", startTagHead)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            (("head", "body", "html", "br"), endTagImplyHead)
+        ])
+        endTagHandler.default = endTagOther
+
     class InHeadPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("title", self.startTagTitle),
-                (("noframes", "style"), self.startTagNoFramesStyle),
-                ("noscript", self.startTagNoscript),
-                ("script", self.startTagScript),
-                (("base", "basefont", "bgsound", "command", "link"),
-                 self.startTagBaseLinkCommand),
-                ("meta", self.startTagMeta),
-                ("head", self.startTagHead)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("head", self.endTagHead),
-                (("br", "html", "body"), self.endTagHtmlBodyBr)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         # the real thing
         def processEOF(self):
@@ -801,22 +815,27 @@ def endTagOther(self, token):
         def anythingElse(self):
             self.endTagHead(impliedTagToken("head"))
 
-    class InHeadNoscriptPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                (("basefont", "bgsound", "link", "meta", "noframes", "style"), self.startTagBaseLinkCommand),
-                (("head", "noscript"), self.startTagHeadNoscript),
-            ])
-            self.startTagHandler.default = self.startTagOther
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml),
+            ("title", startTagTitle),
+            (("noframes", "style"), startTagNoFramesStyle),
+            ("noscript", startTagNoscript),
+            ("script", startTagScript),
+            (("base", "basefont", "bgsound", "command", "link"),
+             startTagBaseLinkCommand),
+            ("meta", startTagMeta),
+            ("head", startTagHead)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("head", endTagHead),
+            (("br", "html", "body"), endTagHtmlBodyBr)
+        ])
+        endTagHandler.default = endTagOther
 
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("noscript", self.endTagNoscript),
-                ("br", self.endTagBr),
-            ])
-            self.endTagHandler.default = self.endTagOther
+    class InHeadNoscriptPhase(Phase):
+        __slots__ = tuple()
 
         def processEOF(self):
             self.parser.parseError("eof-in-head-noscript")
@@ -865,23 +884,21 @@ def anythingElse(self):
             # Caller must raise parse error first!
             self.endTagNoscript(impliedTagToken("noscript"))
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml),
+            (("basefont", "bgsound", "link", "meta", "noframes", "style"), startTagBaseLinkCommand),
+            (("head", "noscript"), startTagHeadNoscript),
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("noscript", endTagNoscript),
+            ("br", endTagBr),
+        ])
+        endTagHandler.default = endTagOther
+
     class AfterHeadPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("body", self.startTagBody),
-                ("frameset", self.startTagFrameset),
-                (("base", "basefont", "bgsound", "link", "meta", "noframes", "script",
-                  "style", "title"),
-                 self.startTagFromHead),
-                ("head", self.startTagHead)
-            ])
-            self.startTagHandler.default = self.startTagOther
-            self.endTagHandler = _utils.MethodDispatcher([(("body", "html", "br"),
-                                                           self.endTagHtmlBodyBr)])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         def processEOF(self):
             self.anythingElse()
@@ -932,80 +949,30 @@ def anythingElse(self):
             self.parser.phase = self.parser.phases["inBody"]
             self.parser.framesetOK = True
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml),
+            ("body", startTagBody),
+            ("frameset", startTagFrameset),
+            (("base", "basefont", "bgsound", "link", "meta", "noframes", "script",
+              "style", "title"),
+             startTagFromHead),
+            ("head", startTagHead)
+        ])
+        startTagHandler.default = startTagOther
+        endTagHandler = _utils.MethodDispatcher([(("body", "html", "br"),
+                                                  endTagHtmlBodyBr)])
+        endTagHandler.default = endTagOther
+
     class InBodyPhase(Phase):
         # http://www.whatwg.org/specs/web-apps/current-work/#parsing-main-inbody
         # the really-really-really-very crazy mode
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
+        __slots__ = ("processSpaceCharacters",)
 
+        def __init__(self, *args, **kwargs):
+            super(InBodyPhase, self).__init__(*args, **kwargs)
             # Set this to the default handler
             self.processSpaceCharacters = self.processSpaceCharactersNonPre
 
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                (("base", "basefont", "bgsound", "command", "link", "meta",
-                  "script", "style", "title"),
-                 self.startTagProcessInHead),
-                ("body", self.startTagBody),
-                ("frameset", self.startTagFrameset),
-                (("address", "article", "aside", "blockquote", "center", "details",
-                  "dir", "div", "dl", "fieldset", "figcaption", "figure",
-                  "footer", "header", "hgroup", "main", "menu", "nav", "ol", "p",
-                  "section", "summary", "ul"),
-                 self.startTagCloseP),
-                (headingElements, self.startTagHeading),
-                (("pre", "listing"), self.startTagPreListing),
-                ("form", self.startTagForm),
-                (("li", "dd", "dt"), self.startTagListItem),
-                ("plaintext", self.startTagPlaintext),
-                ("a", self.startTagA),
-                (("b", "big", "code", "em", "font", "i", "s", "small", "strike",
-                  "strong", "tt", "u"), self.startTagFormatting),
-                ("nobr", self.startTagNobr),
-                ("button", self.startTagButton),
-                (("applet", "marquee", "object"), self.startTagAppletMarqueeObject),
-                ("xmp", self.startTagXmp),
-                ("table", self.startTagTable),
-                (("area", "br", "embed", "img", "keygen", "wbr"),
-                 self.startTagVoidFormatting),
-                (("param", "source", "track"), self.startTagParamSource),
-                ("input", self.startTagInput),
-                ("hr", self.startTagHr),
-                ("image", self.startTagImage),
-                ("isindex", self.startTagIsIndex),
-                ("textarea", self.startTagTextarea),
-                ("iframe", self.startTagIFrame),
-                ("noscript", self.startTagNoscript),
-                (("noembed", "noframes"), self.startTagRawtext),
-                ("select", self.startTagSelect),
-                (("rp", "rt"), self.startTagRpRt),
-                (("option", "optgroup"), self.startTagOpt),
-                (("math"), self.startTagMath),
-                (("svg"), self.startTagSvg),
-                (("caption", "col", "colgroup", "frame", "head",
-                  "tbody", "td", "tfoot", "th", "thead",
-                  "tr"), self.startTagMisplaced)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("body", self.endTagBody),
-                ("html", self.endTagHtml),
-                (("address", "article", "aside", "blockquote", "button", "center",
-                  "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure",
-                  "footer", "header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre",
-                  "section", "summary", "ul"), self.endTagBlock),
-                ("form", self.endTagForm),
-                ("p", self.endTagP),
-                (("dd", "dt", "li"), self.endTagListItem),
-                (headingElements, self.endTagHeading),
-                (("a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
-                  "strike", "strong", "tt", "u"), self.endTagFormatting),
-                (("applet", "marquee", "object"), self.endTagAppletMarqueeObject),
-                ("br", self.endTagBr),
-            ])
-            self.endTagHandler.default = self.endTagOther
-
         def isMatchingFormattingElement(self, node1, node2):
             return (node1.name == node2.name and
                     node1.namespace == node2.namespace and
@@ -1655,14 +1622,73 @@ def endTagOther(self, token):
                         self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
                         break
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            (("base", "basefont", "bgsound", "command", "link", "meta",
+              "script", "style", "title"),
+             startTagProcessInHead),
+            ("body", startTagBody),
+            ("frameset", startTagFrameset),
+            (("address", "article", "aside", "blockquote", "center", "details",
+              "dir", "div", "dl", "fieldset", "figcaption", "figure",
+              "footer", "header", "hgroup", "main", "menu", "nav", "ol", "p",
+              "section", "summary", "ul"),
+             startTagCloseP),
+            (headingElements, startTagHeading),
+            (("pre", "listing"), startTagPreListing),
+            ("form", startTagForm),
+            (("li", "dd", "dt"), startTagListItem),
+            ("plaintext", startTagPlaintext),
+            ("a", startTagA),
+            (("b", "big", "code", "em", "font", "i", "s", "small", "strike",
+              "strong", "tt", "u"), startTagFormatting),
+            ("nobr", startTagNobr),
+            ("button", startTagButton),
+            (("applet", "marquee", "object"), startTagAppletMarqueeObject),
+            ("xmp", startTagXmp),
+            ("table", startTagTable),
+            (("area", "br", "embed", "img", "keygen", "wbr"),
+             startTagVoidFormatting),
+            (("param", "source", "track"), startTagParamSource),
+            ("input", startTagInput),
+            ("hr", startTagHr),
+            ("image", startTagImage),
+            ("isindex", startTagIsIndex),
+            ("textarea", startTagTextarea),
+            ("iframe", startTagIFrame),
+            ("noscript", startTagNoscript),
+            (("noembed", "noframes"), startTagRawtext),
+            ("select", startTagSelect),
+            (("rp", "rt"), startTagRpRt),
+            (("option", "optgroup"), startTagOpt),
+            (("math"), startTagMath),
+            (("svg"), startTagSvg),
+            (("caption", "col", "colgroup", "frame", "head",
+              "tbody", "td", "tfoot", "th", "thead",
+              "tr"), startTagMisplaced)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("body", endTagBody),
+            ("html", endTagHtml),
+            (("address", "article", "aside", "blockquote", "button", "center",
+              "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure",
+              "footer", "header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre",
+              "section", "summary", "ul"), endTagBlock),
+            ("form", endTagForm),
+            ("p", endTagP),
+            (("dd", "dt", "li"), endTagListItem),
+            (headingElements, endTagHeading),
+            (("a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
+              "strike", "strong", "tt", "u"), endTagFormatting),
+            (("applet", "marquee", "object"), endTagAppletMarqueeObject),
+            ("br", endTagBr),
+        ])
+        endTagHandler.default = endTagOther
+
     class TextPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-            self.startTagHandler = _utils.MethodDispatcher([])
-            self.startTagHandler.default = self.startTagOther
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("script", self.endTagScript)])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         def processCharacters(self, token):
             self.tree.insertText(token["data"])
@@ -1688,30 +1714,15 @@ def endTagOther(self, token):
             self.tree.openElements.pop()
             self.parser.phase = self.parser.originalPhase
 
+        startTagHandler = _utils.MethodDispatcher([])
+        startTagHandler.default = startTagOther
+        endTagHandler = _utils.MethodDispatcher([
+            ("script", endTagScript)])
+        endTagHandler.default = endTagOther
+
     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([
-                ("html", self.startTagHtml),
-                ("caption", self.startTagCaption),
-                ("colgroup", self.startTagColgroup),
-                ("col", self.startTagCol),
-                (("tbody", "tfoot", "thead"), self.startTagRowGroup),
-                (("td", "th", "tr"), self.startTagImplyTbody),
-                ("table", self.startTagTable),
-                (("style", "script"), self.startTagStyleScript),
-                ("input", self.startTagInput),
-                ("form", self.startTagForm)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("table", self.endTagTable),
-                (("body", "caption", "col", "colgroup", "html", "tbody", "td",
-                  "tfoot", "th", "thead", "tr"), self.endTagIgnore)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         # helper methods
         def clearStackToTableContext(self):
@@ -1833,9 +1844,32 @@ def endTagOther(self, token):
             self.parser.phases["inBody"].processEndTag(token)
             self.tree.insertFromTable = False
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            ("caption", startTagCaption),
+            ("colgroup", startTagColgroup),
+            ("col", startTagCol),
+            (("tbody", "tfoot", "thead"), startTagRowGroup),
+            (("td", "th", "tr"), startTagImplyTbody),
+            ("table", startTagTable),
+            (("style", "script"), startTagStyleScript),
+            ("input", startTagInput),
+            ("form", startTagForm)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("table", endTagTable),
+            (("body", "caption", "col", "colgroup", "html", "tbody", "td",
+              "tfoot", "th", "thead", "tr"), endTagIgnore)
+        ])
+        endTagHandler.default = endTagOther
+
     class InTableTextPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
+        __slots__ = ("originalPhase", "characterTokens")
+
+        def __init__(self, *args, **kwargs):
+            super(InTableTextPhase, self).__init__(*args, **kwargs)
             self.originalPhase = None
             self.characterTokens = []
 
@@ -1880,23 +1914,7 @@ def processEndTag(self, token):
 
     class InCaptionPhase(Phase):
         # http://www.whatwg.org/specs/web-apps/current-work/#in-caption
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            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([
-                ("caption", self.endTagCaption),
-                ("table", self.endTagTable),
-                (("body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
-                  "thead", "tr"), self.endTagIgnore)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         def ignoreEndTagCaption(self):
             return not self.tree.elementInScope("caption", variant="table")
@@ -1949,23 +1967,24 @@ def endTagIgnore(self, token):
         def endTagOther(self, token):
             return self.parser.phases["inBody"].processEndTag(token)
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
+              "thead", "tr"), startTagTableElement)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("caption", endTagCaption),
+            ("table", endTagTable),
+            (("body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
+              "thead", "tr"), endTagIgnore)
+        ])
+        endTagHandler.default = endTagOther
+
     class InColumnGroupPhase(Phase):
         # http://www.whatwg.org/specs/web-apps/current-work/#in-column
-
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("col", self.startTagCol)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("colgroup", self.endTagColgroup),
-                ("col", self.endTagCol)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         def ignoreEndTagColgroup(self):
             return self.tree.openElements[-1].name == "html"
@@ -2015,26 +2034,21 @@ def endTagOther(self, token):
             if not ignoreEndTag:
                 return token
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            ("col", startTagCol)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("colgroup", endTagColgroup),
+            ("col", endTagCol)
+        ])
+        endTagHandler.default = endTagOther
+
     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([
-                ("html", self.startTagHtml),
-                ("tr", self.startTagTr),
-                (("td", "th"), self.startTagTableCell),
-                (("caption", "col", "colgroup", "tbody", "tfoot", "thead"),
-                 self.startTagTableOther)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                (("tbody", "tfoot", "thead"), self.endTagTableRowGroup),
-                ("table", self.endTagTable),
-                (("body", "caption", "col", "colgroup", "html", "td", "th",
-                  "tr"), self.endTagIgnore)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         # helper methods
         def clearStackToTableBodyContext(self):
@@ -2113,26 +2127,26 @@ def endTagIgnore(self, token):
         def endTagOther(self, token):
             return self.parser.phases["inTable"].processEndTag(token)
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            ("tr", startTagTr),
+            (("td", "th"), startTagTableCell),
+            (("caption", "col", "colgroup", "tbody", "tfoot", "thead"),
+             startTagTableOther)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            (("tbody", "tfoot", "thead"), endTagTableRowGroup),
+            ("table", endTagTable),
+            (("body", "caption", "col", "colgroup", "html", "td", "th",
+              "tr"), endTagIgnore)
+        ])
+        endTagHandler.default = endTagOther
+
     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([
-                ("html", self.startTagHtml),
-                (("td", "th"), self.startTagTableCell),
-                (("caption", "col", "colgroup", "tbody", "tfoot", "thead",
-                  "tr"), self.startTagTableOther)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("tr", self.endTagTr),
-                ("table", self.endTagTable),
-                (("tbody", "tfoot", "thead"), self.endTagTableRowGroup),
-                (("body", "caption", "col", "colgroup", "html", "td", "th"),
-                 self.endTagIgnore)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         # helper methods (XXX unify this with other table helper methods)
         def clearStackToTableRowContext(self):
@@ -2202,23 +2216,26 @@ def endTagIgnore(self, token):
         def endTagOther(self, token):
             return self.parser.phases["inTable"].processEndTag(token)
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            (("td", "th"), startTagTableCell),
+            (("caption", "col", "colgroup", "tbody", "tfoot", "thead",
+              "tr"), startTagTableOther)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("tr", endTagTr),
+            ("table", endTagTable),
+            (("tbody", "tfoot", "thead"), endTagTableRowGroup),
+            (("body", "caption", "col", "colgroup", "html", "td", "th"),
+             endTagIgnore)
+        ])
+        endTagHandler.default = endTagOther
+
     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([
-                ("html", self.startTagHtml),
-                (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
-                  "thead", "tr"), self.startTagTableOther)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                (("td", "th"), self.endTagTableCell),
-                (("body", "caption", "col", "colgroup", "html"), self.endTagIgnore),
-                (("table", "tbody", "tfoot", "thead", "tr"), self.endTagImply)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         # helper
         def closeCell(self):
@@ -2278,26 +2295,22 @@ def endTagImply(self, token):
         def endTagOther(self, token):
             return self.parser.phases["inBody"].processEndTag(token)
 
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
+              "thead", "tr"), startTagTableOther)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            (("td", "th"), endTagTableCell),
+            (("body", "caption", "col", "colgroup", "html"), endTagIgnore),
+            (("table", "tbody", "tfoot", "thead", "tr"), endTagImply)
+        ])
+        endTagHandler.default = endTagOther
+
     class InSelectPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("option", self.startTagOption),
-                ("optgroup", self.startTagOptgroup),
-                ("select", self.startTagSelect),
-                (("input", "keygen", "textarea"), self.startTagInput),
-                ("script", self.startTagScript)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("option", self.endTagOption),
-                ("optgroup", self.endTagOptgroup),
-                ("select", self.endTagSelect)
-            ])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         # http://www.whatwg.org/specs/web-apps/current-work/#in-select
         def processEOF(self):
@@ -2378,21 +2391,25 @@ def endTagOther(self, token):
             self.parser.parseError("unexpected-end-tag-in-select",
                                    {"name": token["name"]})
 
-    class InSelectInTablePhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
-                 self.startTagTable)
-            ])
-            self.startTagHandler.default = self.startTagOther
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            ("option", startTagOption),
+            ("optgroup", startTagOptgroup),
+            ("select", startTagSelect),
+            (("input", "keygen", "textarea"), startTagInput),
+            ("script", startTagScript)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            ("option", endTagOption),
+            ("optgroup", endTagOptgroup),
+            ("select", endTagSelect)
+        ])
+        endTagHandler.default = endTagOther
 
-            self.endTagHandler = _utils.MethodDispatcher([
-                (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
-                 self.endTagTable)
-            ])
-            self.endTagHandler.default = self.endTagOther
+    class InSelectInTablePhase(Phase):
+        __slots__ = tuple()
 
         def processEOF(self):
             self.parser.phases["inSelect"].processEOF()
@@ -2417,7 +2434,21 @@ def endTagTable(self, token):
         def endTagOther(self, token):
             return self.parser.phases["inSelect"].processEndTag(token)
 
+        startTagHandler = _utils.MethodDispatcher([
+            (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
+             startTagTable)
+        ])
+        startTagHandler.default = startTagOther
+
+        endTagHandler = _utils.MethodDispatcher([
+            (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
+             endTagTable)
+        ])
+        endTagHandler.default = endTagOther
+
     class InForeignContentPhase(Phase):
+        __slots__ = tuple()
+
         breakoutElements = frozenset(["b", "big", "blockquote", "body", "br",
                                       "center", "code", "dd", "div", "dl", "dt",
                                       "em", "embed", "h1", "h2", "h3",
@@ -2427,9 +2458,6 @@ class InForeignContentPhase(Phase):
                                       "span", "strong", "strike", "sub", "sup",
                                       "table", "tt", "u", "ul", "var"])
 
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
         def adjustSVGTagNames(self, token):
             replacements = {"altglyph": "altGlyph",
                             "altglyphdef": "altGlyphDef",
@@ -2533,16 +2561,7 @@ def processEndTag(self, token):
             return new_token
 
     class AfterBodyPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
-
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml)
-            ])
-            self.startTagHandler.default = self.startTagOther
-
-            self.endTagHandler = _utils.MethodDispatcher([("html", self.endTagHtml)])
-            self.endTagHandler.default = self.endTagOther
+        __slots__ = tuple()
 
         def processEOF(self):
             # Stop parsing
@@ -2579,23 +2598,17 @@ def endTagOther(self, token):
             self.parser.phase = self.parser.phases["inBody"]
             return token
 
-    class InFramesetPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml)
+        ])
+        startTagHandler.default = startTagOther
 
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("frameset", self.startTagFrameset),
-                ("frame", self.startTagFrame),
-                ("noframes", self.startTagNoframes)
-            ])
-            self.startTagHandler.default = self.startTagOther
+        endTagHandler = _utils.MethodDispatcher([("html", endTagHtml)])
+        endTagHandler.default = endTagOther
 
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("frameset", self.endTagFrameset)
-            ])
-            self.endTagHandler.default = self.endTagOther
+    class InFramesetPhase(Phase):
+        # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset
+        __slots__ = tuple()
 
         def processEOF(self):
             if self.tree.openElements[-1].name != "html":
@@ -2636,21 +2649,22 @@ def endTagOther(self, token):
             self.parser.parseError("unexpected-end-tag-in-frameset",
                                    {"name": token["name"]})
 
-    class AfterFramesetPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#after3
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            ("frameset", startTagFrameset),
+            ("frame", startTagFrame),
+            ("noframes", startTagNoframes)
+        ])
+        startTagHandler.default = startTagOther
 
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("noframes", self.startTagNoframes)
-            ])
-            self.startTagHandler.default = self.startTagOther
+        endTagHandler = _utils.MethodDispatcher([
+            ("frameset", endTagFrameset)
+        ])
+        endTagHandler.default = endTagOther
 
-            self.endTagHandler = _utils.MethodDispatcher([
-                ("html", self.endTagHtml)
-            ])
-            self.endTagHandler.default = self.endTagOther
+    class AfterFramesetPhase(Phase):
+        # http://www.whatwg.org/specs/web-apps/current-work/#after3
+        __slots__ = tuple()
 
         def processEOF(self):
             # Stop parsing
@@ -2673,14 +2687,19 @@ def endTagOther(self, token):
             self.parser.parseError("unexpected-end-tag-after-frameset",
                                    {"name": token["name"]})
 
-    class AfterAfterBodyPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", Phase.startTagHtml),
+            ("noframes", startTagNoframes)
+        ])
+        startTagHandler.default = startTagOther
 
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml)
-            ])
-            self.startTagHandler.default = self.startTagOther
+        endTagHandler = _utils.MethodDispatcher([
+            ("html", endTagHtml)
+        ])
+        endTagHandler.default = endTagOther
+
+    class AfterAfterBodyPhase(Phase):
+        __slots__ = tuple()
 
         def processEOF(self):
             pass
@@ -2711,15 +2730,13 @@ def processEndTag(self, token):
             self.parser.phase = self.parser.phases["inBody"]
             return token
 
-    class AfterAfterFramesetPhase(Phase):
-        def __init__(self, parser, tree):
-            Phase.__init__(self, parser, tree)
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml)
+        ])
+        startTagHandler.default = startTagOther
 
-            self.startTagHandler = _utils.MethodDispatcher([
-                ("html", self.startTagHtml),
-                ("noframes", self.startTagNoFrames)
-            ])
-            self.startTagHandler.default = self.startTagOther
+    class AfterAfterFramesetPhase(Phase):
+        __slots__ = tuple()
 
         def processEOF(self):
             pass
@@ -2746,6 +2763,13 @@ def startTagOther(self, token):
         def processEndTag(self, token):
             self.parser.parseError("expected-eof-but-got-end-tag",
                                    {"name": token["name"]})
+
+        startTagHandler = _utils.MethodDispatcher([
+            ("html", startTagHtml),
+            ("noframes", startTagNoFrames)
+        ])
+        startTagHandler.default = startTagOther
+
     # pylint:enable=unused-argument
 
     return {

From b2e4802246d131c52f9a58cfdf8677cab3855a56 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Sat, 16 May 2020 01:13:51 +0100
Subject: [PATCH 071/105] Speedup setting attributes on etree implementations

---
 html5lib/treebuilders/etree.py      | 27 ++++++++------
 html5lib/treebuilders/etree_lxml.py | 58 ++++++++++++++++++++---------
 2 files changed, 55 insertions(+), 30 deletions(-)

diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py
index cb1d4aef..086bed4e 100644
--- a/html5lib/treebuilders/etree.py
+++ b/html5lib/treebuilders/etree.py
@@ -5,6 +5,8 @@
 
 import re
 
+from copy import copy
+
 from . import base
 from .. import _ihatexml
 from .. import constants
@@ -61,16 +63,17 @@ def _getAttributes(self):
             return self._element.attrib
 
         def _setAttributes(self, attributes):
-            # Delete existing attributes first
-            # XXX - there may be a better way to do this...
-            for key in list(self._element.attrib.keys()):
-                del self._element.attrib[key]
-            for key, value in attributes.items():
-                if isinstance(key, tuple):
-                    name = "{%s}%s" % (key[2], key[1])
-                else:
-                    name = key
-                self._element.set(name, value)
+            el_attrib = self._element.attrib
+            el_attrib.clear()
+            if attributes:
+                # calling .items _always_ allocates, and the above truthy check is cheaper than the
+                # allocation on average
+                for key, value in attributes.items():
+                    if isinstance(key, tuple):
+                        name = "{%s}%s" % (key[2], key[1])
+                    else:
+                        name = key
+                    el_attrib[name] = value
 
         attributes = property(_getAttributes, _setAttributes)
 
@@ -129,8 +132,8 @@ def insertText(self, data, insertBefore=None):
 
         def cloneNode(self):
             element = type(self)(self.name, self.namespace)
-            for name, value in self.attributes.items():
-                element.attributes[name] = value
+            if self._element.attrib:
+                element._element.attrib = copy(self._element.attrib)
             return element
 
         def reparentChildren(self, newParent):
diff --git a/html5lib/treebuilders/etree_lxml.py b/html5lib/treebuilders/etree_lxml.py
index 227a0b24..e73de61a 100644
--- a/html5lib/treebuilders/etree_lxml.py
+++ b/html5lib/treebuilders/etree_lxml.py
@@ -16,6 +16,11 @@
 import re
 import sys
 
+try:
+    from collections.abc import MutableMapping
+except ImportError:
+    from collections import MutableMapping
+
 from . import base
 from ..constants import DataLossWarning
 from .. import constants
@@ -23,6 +28,7 @@
 from .. import _ihatexml
 
 import lxml.etree as etree
+from six import PY3, binary_type
 
 
 fullTree = True
@@ -189,26 +195,37 @@ def __init__(self, namespaceHTMLElements, fullTree=False):
         infosetFilter = self.infosetFilter = _ihatexml.InfosetFilter(preventDoubleDashComments=True)
         self.namespaceHTMLElements = namespaceHTMLElements
 
-        class Attributes(dict):
-            def __init__(self, element, value=None):
-                if value is None:
-                    value = {}
+        class Attributes(MutableMapping):
+            def __init__(self, element):
                 self._element = element
-                dict.__init__(self, value)  # pylint:disable=non-parent-init-called
-                for key, value in self.items():
-                    if isinstance(key, tuple):
-                        name = "{%s}%s" % (key[2], infosetFilter.coerceAttribute(key[1]))
-                    else:
-                        name = infosetFilter.coerceAttribute(key)
-                    self._element._element.attrib[name] = value
 
-            def __setitem__(self, key, value):
-                dict.__setitem__(self, key, value)
+            def _coerceKey(self, key):
                 if isinstance(key, tuple):
                     name = "{%s}%s" % (key[2], infosetFilter.coerceAttribute(key[1]))
                 else:
                     name = infosetFilter.coerceAttribute(key)
-                self._element._element.attrib[name] = value
+                return name
+
+            def __getitem__(self, key):
+                value = self._element._element.attrib[self._coerceKey(key)]
+                if not PY3 and isinstance(value, binary_type):
+                    value = value.decode("ascii")
+                return value
+
+            def __setitem__(self, key, value):
+                self._element._element.attrib[self._coerceKey(key)] = value
+
+            def __delitem__(self, key):
+                del self._element._element.attrib[self._coerceKey(key)]
+
+            def __iter__(self):
+                return iter(self._element._element.attrib)
+
+            def __len__(self):
+                return len(self._element._element.attrib)
+
+            def clear(self):
+                return self._element._element.attrib.clear()
 
         class Element(builder.Element):
             def __init__(self, name, namespace):
@@ -229,8 +246,10 @@ def _getName(self):
             def _getAttributes(self):
                 return self._attributes
 
-            def _setAttributes(self, attributes):
-                self._attributes = Attributes(self, attributes)
+            def _setAttributes(self, value):
+                attributes = self.attributes
+                attributes.clear()
+                attributes.update(value)
 
             attributes = property(_getAttributes, _setAttributes)
 
@@ -238,8 +257,11 @@ def insertText(self, data, insertBefore=None):
                 data = infosetFilter.coerceCharacters(data)
                 builder.Element.insertText(self, data, insertBefore)
 
-            def appendChild(self, child):
-                builder.Element.appendChild(self, child)
+            def cloneNode(self):
+                element = type(self)(self.name, self.namespace)
+                if self._element.attrib:
+                    element._element.attrib.update(self._element.attrib)
+                return element
 
         class Comment(builder.Comment):
             def __init__(self, data):

From 38ec086b54c7722f6c7f25895a38ea604ce68111 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Sat, 16 May 2020 05:00:15 +0100
Subject: [PATCH 072/105] Move token normalisation to the tokenizer

---
 html5lib/_tokenizer.py             | 16 +++++++-
 html5lib/html5parser.py            | 31 ++------------
 html5lib/tests/test_parser2.py     | 40 +-----------------
 html5lib/tests/test_tokenizer2.py  | 66 ++++++++++++++++++++++++++++++
 html5lib/tests/test_treewalkers.py | 64 +++++++++++++++++++++++++++++
 html5lib/tests/tokenizer.py        |  2 +-
 6 files changed, 151 insertions(+), 68 deletions(-)
 create mode 100644 html5lib/tests/test_tokenizer2.py

diff --git a/html5lib/_tokenizer.py b/html5lib/_tokenizer.py
index 6078f66a..4748a197 100644
--- a/html5lib/_tokenizer.py
+++ b/html5lib/_tokenizer.py
@@ -2,7 +2,8 @@
 
 from six import unichr as chr
 
-from collections import deque
+from collections import deque, OrderedDict
+from sys import version_info
 
 from .constants import spaceCharacters
 from .constants import entities
@@ -17,6 +18,11 @@
 
 entitiesTrie = Trie(entities)
 
+if version_info >= (3, 7):
+    attributeMap = dict
+else:
+    attributeMap = OrderedDict
+
 
 class HTMLTokenizer(object):
     """ This class takes care of tokenizing HTML.
@@ -228,6 +234,14 @@ def emitCurrentToken(self):
         # Add token to the queue to be yielded
         if (token["type"] in tagTokenTypes):
             token["name"] = token["name"].translate(asciiUpper2Lower)
+            if token["type"] == tokenTypes["StartTag"]:
+                raw = token["data"]
+                data = attributeMap(raw)
+                if len(raw) > len(data):
+                    # we had some duplicated attribute, fix so first wins
+                    data.update(raw[::-1])
+                token["data"] = data
+
             if token["type"] == tokenTypes["EndTag"]:
                 if token["data"]:
                     self.tokenQueue.append({"type": tokenTypes["ParseError"],
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index fe155aec..74d829d9 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -3,9 +3,6 @@
 
 import types
 
-from collections import OrderedDict
-from sys import version_info
-
 from . import _inputstream
 from . import _tokenizer
 
@@ -26,12 +23,6 @@
 )
 
 
-if version_info >= (3, 7):
-    attributeMap = dict
-else:
-    attributeMap = OrderedDict
-
-
 def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
     """Parse an HTML document as a string or file-like object into a tree
 
@@ -210,7 +201,7 @@ def mainLoop(self):
         DoctypeToken = tokenTypes["Doctype"]
         ParseErrorToken = tokenTypes["ParseError"]
 
-        for token in self.normalizedTokens():
+        for token in self.tokenizer:
             prev_token = None
             new_token = token
             while new_token is not None:
@@ -268,10 +259,6 @@ def mainLoop(self):
             if reprocess:
                 assert self.phase not in phases
 
-    def normalizedTokens(self):
-        for token in self.tokenizer:
-            yield self.normalizeToken(token)
-
     def parse(self, stream, *args, **kwargs):
         """Parse a HTML document into a well-formed tree
 
@@ -333,18 +320,6 @@ def parseError(self, errorcode="XXX-undefined-error", datavars=None):
         if self.strict:
             raise ParseError(E[errorcode] % datavars)
 
-    def normalizeToken(self, token):
-        # HTML5 specific normalizations to the token stream
-        if token["type"] == tokenTypes["StartTag"]:
-            raw = token["data"]
-            data = attributeMap(raw)
-            if len(raw) > len(data):
-                # we had some duplicated attribute, fix so first wins
-                data.update(raw[::-1])
-            token["data"] = data
-
-        return token
-
     def adjustMathMLAttributes(self, token):
         adjust_attributes(token, adjustMathMLAttributes)
 
@@ -2803,8 +2778,8 @@ def processEndTag(self, token):
 def adjust_attributes(token, replacements):
     needs_adjustment = viewkeys(token['data']) & viewkeys(replacements)
     if needs_adjustment:
-        token['data'] = attributeMap((replacements.get(k, k), v)
-                                     for k, v in token['data'].items())
+        token['data'] = type(token['data'])((replacements.get(k, k), v)
+                                            for k, v in token['data'].items())
 
 
 def impliedTagToken(name, type="EndTag", attributes=None,
diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py
index bcc0bf48..879d2447 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, unichr
+from six import PY2, text_type
 
 import io
 
 from . import support  # noqa
 
-from html5lib.constants import namespaces, tokenTypes
+from html5lib.constants import namespaces
 from html5lib import parse, parseFragment, HTMLParser
 
 
@@ -53,42 +53,6 @@ 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('<p class=a class=b>')
-    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("<!doctype html><title>a</title><p>b<script>c</script>d</p>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("<span " + " ".join("%s='%s'" % (x, i) for x, i in attrs) + ">")
+
+    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("<span a=1 a=2 a=3>")
+
+    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("<span " + " ".join("%s='%s'" % (x, i) for x, i in attrs) + " a=100>")
+
+    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 = "<span " + " ".join("%s='%s'" % (x, i) for x, i in attrs) + ">"
+
+    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 = "<svg a=1 refx=2 b=3 xml:lang=4 c=5>"
+
+    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 list(attrs_out.items()) == [((None, 'a'), '1'),
+                                       ((None, 'refX'), '2'),
+                                       ((None, 'b'), '3'),
+                                       (('http://www.w3.org/XML/1998/namespace', 'lang'), '4'),
+                                       ((None, 'c'), '5')]
diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index 706d0e6f..47264cc3 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -40,7 +40,7 @@ def processDoctype(self, token):
 
     def processStartTag(self, token):
         self.outputTokens.append(["StartTag", token["name"],
-                                  dict(token["data"][::-1]), token["selfClosing"]])
+                                  token["data"], token["selfClosing"]])
 
     def processEmptyTag(self, token):
         if token["name"] not in constants.voidElements:

From b2b08cc5a27081881bef81ec4c7ed93da02e8206 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Wed, 10 Jun 2020 02:24:42 +0100
Subject: [PATCH 073/105] Get lxml treewalker outputting attrs in source order
 again

Mostly so we have test coverage here on < 3.7
---
 html5lib/tests/test_treewalkers.py | 8 ++++++--
 html5lib/treewalkers/etree_lxml.py | 4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/html5lib/tests/test_treewalkers.py b/html5lib/tests/test_treewalkers.py
index 4a21b479..780ca964 100644
--- a/html5lib/tests/test_treewalkers.py
+++ b/html5lib/tests/test_treewalkers.py
@@ -141,7 +141,9 @@ def test_lxml_xml():
 
 @pytest.mark.parametrize("treeName",
                          [pytest.param(treeName, marks=[getattr(pytest.mark, treeName),
-                                                        pytest.mark.skipif(sys.version_info < (3, 7), reason="dict order undef")])
+                                                        pytest.mark.skipif(
+                                                            treeName != "lxml" or
+                                                            sys.version_info < (3, 7), reason="dict order undef")])
                           for treeName in sorted(treeTypes.keys())])
 def test_maintain_attribute_order(treeName):
     treeAPIs = treeTypes[treeName]
@@ -172,7 +174,9 @@ def test_maintain_attribute_order(treeName):
 
 @pytest.mark.parametrize("treeName",
                          [pytest.param(treeName, marks=[getattr(pytest.mark, treeName),
-                                                        pytest.mark.skipif(sys.version_info < (3, 7), reason="dict order undef")])
+                                                        pytest.mark.skipif(
+                                                            treeName != "lxml" or
+                                                            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]
diff --git a/html5lib/treewalkers/etree_lxml.py b/html5lib/treewalkers/etree_lxml.py
index fb236311..a614ac5b 100644
--- a/html5lib/treewalkers/etree_lxml.py
+++ b/html5lib/treewalkers/etree_lxml.py
@@ -1,6 +1,8 @@
 from __future__ import absolute_import, division, unicode_literals
 from six import text_type
 
+from collections import OrderedDict
+
 from lxml import etree
 from ..treebuilders.etree import tag_regexp
 
@@ -163,7 +165,7 @@ def getNodeDetails(self, node):
             else:
                 namespace = None
                 tag = ensure_str(node.tag)
-            attrs = {}
+            attrs = OrderedDict()
             for name, value in list(node.attrib.items()):
                 name = ensure_str(name)
                 value = ensure_str(value)

From 7e52b16e50bd0e6683096177e6d1fb668d65c522 Mon Sep 17 00:00:00 2001
From: Christian Heimes <christian@python.org>
Date: Thu, 21 May 2020 00:17:55 +0200
Subject: [PATCH 074/105] Don't use cElementTree on Python 3

It's been deprecated and will be removed in 3.9 or 3.10. 3.9.0b1 doesn't
have cElementTree. I'd like to bring it back with a deprecation warning
to drop in 3.10.

See: https://github.com/python/cpython/pull/19921
Signed-off-by: Christian Heimes <christian@python.org>
Signed-off-by: Sam Sneddon <me@gsnedders.com>
---
 html5lib/_utils.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/html5lib/_utils.py b/html5lib/_utils.py
index 179d7015..9ea57942 100644
--- a/html5lib/_utils.py
+++ b/html5lib/_utils.py
@@ -7,12 +7,15 @@
 except ImportError:
     from collections import Mapping
 
-from six import text_type
+from six import text_type, PY3
 
-try:
-    import xml.etree.cElementTree as default_etree
-except ImportError:
+if PY3:
     import xml.etree.ElementTree as default_etree
+else:
+    try:
+        import xml.etree.cElementTree as default_etree
+    except ImportError:
+        import xml.etree.ElementTree as default_etree
 
 
 __all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",

From 8df6cc90c7b12598ddb9e25eab64a6d1eb04d661 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Sun, 21 Jun 2020 21:01:10 +0100
Subject: [PATCH 075/105] Deprecate the sanitizer and recommend Bleach (#501)

---
 CHANGES.rst                      | 13 ++++++++++---
 html5lib/filters/sanitizer.py    | 20 ++++++++++++++++++++
 html5lib/tests/sanitizer.py      | 17 +++++++++--------
 html5lib/tests/test_sanitizer.py | 17 +++++++++--------
 4 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index abc7bb18..fcb22475 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -11,11 +11,18 @@ Breaking changes:
 * Drop support for Python 3.3. (#358)
 * Drop support for Python 3.4. (#421)
 
+Deprecations:
+
+* Deprecate the ``html5lib`` sanitizer (``html5lib.serialize(sanitize=True)`` and
+  ``html5lib.filters.sanitizer``). We recommend users migrate to `Bleach
+  <https://github.com/mozilla/bleach>`. Please let us know if Bleach doesn't suffice for your
+  use. (#443)
+
 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)
+* 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/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index e852f53b..70ef9066 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -1,6 +1,15 @@
+"""Deprecated from html5lib 1.1.
+
+See `here <https://github.com/html5lib/html5lib-python/issues/443>`_ for
+information about its deprecation; `Bleach <https://github.com/mozilla/bleach>`_
+is recommended as a replacement. Please let us know in the aforementioned issue
+if Bleach is unsuitable for your needs.
+
+"""
 from __future__ import absolute_import, division, unicode_literals
 
 import re
+import warnings
 from xml.sax.saxutils import escape, unescape
 
 from six.moves import urllib_parse as urlparse
@@ -11,6 +20,14 @@
 __all__ = ["Filter"]
 
 
+_deprecation_msg = (
+    "html5lib's sanitizer is deprecated; see " +
+    "https://github.com/html5lib/html5lib-python/issues/443 and please let " +
+    "us know if Bleach is unsuitable for your needs"
+)
+
+warnings.warn(_deprecation_msg, DeprecationWarning)
+
 allowed_elements = frozenset((
     (namespaces['html'], 'a'),
     (namespaces['html'], 'abbr'),
@@ -750,6 +767,9 @@ def __init__(self,
 
         """
         super(Filter, self).__init__(source)
+
+        warnings.warn(_deprecation_msg, DeprecationWarning)
+
         self.allowed_elements = allowed_elements
         self.allowed_attributes = allowed_attributes
         self.allowed_css_properties = allowed_css_properties
diff --git a/html5lib/tests/sanitizer.py b/html5lib/tests/sanitizer.py
index 93882ec4..bb483421 100644
--- a/html5lib/tests/sanitizer.py
+++ b/html5lib/tests/sanitizer.py
@@ -27,14 +27,15 @@ def runtest(self):
         expected = self.test["output"]
 
         parsed = parseFragment(input)
-        serialized = serialize(parsed,
-                               sanitize=True,
-                               omit_optional_tags=False,
-                               use_trailing_solidus=True,
-                               space_before_trailing_solidus=False,
-                               quote_attr_values="always",
-                               quote_char="'",
-                               alphabetical_attributes=True)
+        with pytest.deprecated_call():
+            serialized = serialize(parsed,
+                                   sanitize=True,
+                                   omit_optional_tags=False,
+                                   use_trailing_solidus=True,
+                                   space_before_trailing_solidus=False,
+                                   quote_attr_values="always",
+                                   quote_char="'",
+                                   alphabetical_attributes=True)
         errorMsg = "\n".join(["\n\nInput:", input,
                               "\nExpected:", expected,
                               "\nReceived:", serialized])
diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index 9a8e7f2d..f3faeb80 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -8,14 +8,15 @@
 
 def sanitize_html(stream):
     parsed = parseFragment(stream)
-    serialized = serialize(parsed,
-                           sanitize=True,
-                           omit_optional_tags=False,
-                           use_trailing_solidus=True,
-                           space_before_trailing_solidus=False,
-                           quote_attr_values="always",
-                           quote_char='"',
-                           alphabetical_attributes=True)
+    with pytest.deprecated_call():
+        serialized = serialize(parsed,
+                               sanitize=True,
+                               omit_optional_tags=False,
+                               use_trailing_solidus=True,
+                               space_before_trailing_solidus=False,
+                               quote_attr_values="always",
+                               quote_char='"',
+                               alphabetical_attributes=True)
     return serialized
 
 

From f87487a4ada2d6cf223bdd182774a01ba3c84618 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Tue, 23 Jun 2020 00:27:42 +0100
Subject: [PATCH 076/105] Bump version for release

---
 html5lib/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 373fb925..320e0c3b 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.1-dev"
+__version__ = "1.1"

From f4646e6ed4eeb9780f67d2083d0c09c8fffbec53 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Tue, 23 Jun 2020 00:36:46 +0100
Subject: [PATCH 077/105] Bump version number for dev

---
 html5lib/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/html5lib/__init__.py b/html5lib/__init__.py
index 320e0c3b..7b854f99 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.1"
+__version__ = "1.2-dev"

From 569e580d93f550033fde175cac1118ed26941332 Mon Sep 17 00:00:00 2001
From: Sam Sneddon <me@gsnedders.com>
Date: Tue, 23 Jun 2020 00:38:13 +0100
Subject: [PATCH 078/105] Stop running coverage on Travis/AppVeyor

---
 .appveyor.yml | 6 +-----
 .travis.yml   | 6 +-----
 tox.ini       | 2 +-
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 92f34f15..a1a3e347 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -2,7 +2,6 @@
 environment:
   global:
     PATH: "C:\\Python27\\Scripts\\;%PATH%"
-    PYTEST_COMMAND: "coverage run -m pytest"
   matrix:
     - TOXENV: py27-base
     - TOXENV: py27-optional
@@ -17,7 +16,7 @@ environment:
 
 install:
   - git submodule update --init --recursive
-  - python -m pip install tox codecov
+  - python -m pip install tox
 
 build: off
 
@@ -26,6 +25,3 @@ test_script:
 
 after_test:
   - python debug-info.py
-
-on_success:
-  - codecov
diff --git a/.travis.yml b/.travis.yml
index 6561e2a3..d2d9e30e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,17 +13,13 @@ cache: pip
 
 env:
   global:
-    - PYTEST_COMMAND="coverage run -m pytest"
     - TOXENV=base,optional,six19-optional
 
 install:
-  - pip install tox codecov
+  - pip install tox
 
 script:
   - tox
 
 after_script:
   - python debug-info.py
-
-after_success:
-  - codecov
diff --git a/tox.ini b/tox.ini
index 58758cea..16b8cf41 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,7 @@ deps =
   doc: Sphinx
 
 passenv =
-  PYTEST_COMMAND
+  PYTEST_COMMAND  # this is maintained so one can, e.g., PYTEST_COMMAND="coverage run -m pytest"
   COVERAGE_RUN_OPTIONS
 commands =
   six19: pip install six==1.9

From a7c18875fd6136da8ef6a9075bf944e45643e8d1 Mon Sep 17 00:00:00 2001
From: Sergey Fursov <GeyseR85@gmail.com>
Date: Fri, 26 Jun 2020 11:48:45 +0300
Subject: [PATCH 079/105] changelog: the 1.1 version has been released

---
 CHANGES.rst | 2 --
 1 file changed, 2 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index fcb22475..0f6314aa 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,8 +4,6 @@ Change Log
 1.1
 ~~~
 
-UNRELEASED
-
 Breaking changes:
 
 * Drop support for Python 3.3. (#358)

From 2c19b9899ab3a3e8bd0ca35e5d78544334204169 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Sat, 8 Aug 2020 13:39:22 +0200
Subject: [PATCH 080/105] Use Node.from_parent() constructor to support pytest
 6

Add a wrapper not to break pytest 4 (needed for Python 2 support).

    ============================= test session starts ==============================
    platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
    rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
    plugins: expect-1.1.0
    collected 0 items / 1 error

    ==================================== ERRORS ====================================
    ________________________ ERROR collecting test session _________________________
    /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    html5lib/tests/conftest.py:105: in pytest_collect_file
        return TokenizerFile(path, parent)
    /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
        warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
    E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
    E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

Fixes https://github.com/html5lib/html5lib-python/issues/505
---
 html5lib/tests/conftest.py          | 15 ++++++++++++---
 html5lib/tests/sanitizer.py         |  2 +-
 html5lib/tests/tokenizer.py         | 10 +++++-----
 html5lib/tests/tree_construction.py | 20 ++++++++++----------
 requirements-test.txt               |  2 +-
 5 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py
index dad167c5..fffeb50c 100644
--- a/html5lib/tests/conftest.py
+++ b/html5lib/tests/conftest.py
@@ -99,10 +99,19 @@ def pytest_collect_file(path, parent):
 
     if _tree_construction in dir_and_parents:
         if path.ext == ".dat":
-            return TreeConstructionFile(path, parent)
+            return TreeConstructionFile.from_parent(parent, fspath=path)
     elif _tokenizer in dir_and_parents:
         if path.ext == ".test":
-            return TokenizerFile(path, parent)
+            return TokenizerFile.from_parent(parent, fspath=path)
     elif _sanitizer_testdata in dir_and_parents:
         if path.ext == ".dat":
-            return SanitizerFile(path, parent)
+            return SanitizerFile.from_parent(parent, fspath=path)
+
+
+# Tiny wrapper to allow .from_parent constructors on older pytest for PY27
+if not hasattr(pytest.Item.__base__, "from_parent"):
+    @classmethod
+    def from_parent(cls, parent, **kwargs):
+        return cls(parent=parent, **kwargs)
+
+    pytest.Item.__base__.from_parent = from_parent
diff --git a/html5lib/tests/sanitizer.py b/html5lib/tests/sanitizer.py
index bb483421..16e53868 100644
--- a/html5lib/tests/sanitizer.py
+++ b/html5lib/tests/sanitizer.py
@@ -13,7 +13,7 @@ def collect(self):
         with codecs.open(str(self.fspath), "r", encoding="utf-8") as fp:
             tests = json.load(fp)
         for i, test in enumerate(tests):
-            yield SanitizerTest(str(i), self, test=test)
+            yield SanitizerTest.from_parent(self, name=str(i), test=test)
 
 
 class SanitizerTest(pytest.Item):
diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index 47264cc3..cc9897a4 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -192,7 +192,7 @@ def collect(self):
             tests = json.load(fp)
         if 'tests' in tests:
             for i, test in enumerate(tests['tests']):
-                yield TokenizerTestCollector(str(i), self, testdata=test)
+                yield TokenizerTestCollector.from_parent(self, name=str(i), testdata=test)
 
 
 class TokenizerTestCollector(pytest.Collector):
@@ -207,10 +207,10 @@ def __init__(self, name, parent=None, config=None, session=None, testdata=None):
     def collect(self):
         for initialState in self.testdata["initialStates"]:
             initialState = capitalize(initialState)
-            item = TokenizerTest(initialState,
-                                 self,
-                                 self.testdata,
-                                 initialState)
+            item = TokenizerTest.from_parent(self,
+                                             name=initialState,
+                                             test=self.testdata,
+                                             initialState=initialState)
             if self.testdata["input"] is None:
                 item.add_marker(pytest.mark.skipif(True, reason="Relies on lone surrogates"))
             yield item
diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py
index 1ef6e725..fb0657bf 100644
--- a/html5lib/tests/tree_construction.py
+++ b/html5lib/tests/tree_construction.py
@@ -26,7 +26,7 @@ class TreeConstructionFile(pytest.File):
     def collect(self):
         tests = TestData(str(self.fspath), "data")
         for i, test in enumerate(tests):
-            yield TreeConstructionTest(str(i), self, testdata=test)
+            yield TreeConstructionTest.from_parent(self, name=str(i), testdata=test)
 
 
 class TreeConstructionTest(pytest.Collector):
@@ -48,11 +48,11 @@ def _getParserTests(self, treeName, treeAPIs):
                 nodeid = "%s::parser::namespaced" % treeName
             else:
                 nodeid = "%s::parser::void-namespace" % treeName
-            item = ParserTest(nodeid,
-                              self,
-                              self.testdata,
-                              treeAPIs["builder"] if treeAPIs is not None else None,
-                              namespaceHTMLElements)
+            item = ParserTest.from_parent(self,
+                                          name=nodeid,
+                                          test=self.testdata,
+                                          treeClass=treeAPIs["builder"] if treeAPIs is not None else None,
+                                          namespaceHTMLElements=namespaceHTMLElements)
             item.add_marker(getattr(pytest.mark, treeName))
             item.add_marker(pytest.mark.parser)
             if namespaceHTMLElements:
@@ -61,10 +61,10 @@ def _getParserTests(self, treeName, treeAPIs):
 
     def _getTreeWalkerTests(self, treeName, treeAPIs):
         nodeid = "%s::treewalker" % treeName
-        item = TreeWalkerTest(nodeid,
-                              self,
-                              self.testdata,
-                              treeAPIs)
+        item = TreeWalkerTest.from_parent(self,
+                                          name=nodeid,
+                                          test=self.testdata,
+                                          treeAPIs=treeAPIs)
         item.add_marker(getattr(pytest.mark, treeName))
         item.add_marker(pytest.mark.treewalker)
         yield item
diff --git a/requirements-test.txt b/requirements-test.txt
index 703d0e69..57f8f617 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -3,7 +3,7 @@
 tox>=3.15.1,<4
 flake8>=3.8.1,<3.9
 pytest>=4.6.10,<5 ; python_version < '3'
-pytest>=5.4.2,<6 ; python_version >= '3'
+pytest>=5.4.2,<7 ; python_version >= '3'
 coverage>=5.1,<6
 pytest-expect>=1.1.0,<2
 mock>=3.0.5,<4 ; python_version < '3.6'

From 0d24bec641ae88153211d98d1fcc862280f37e43 Mon Sep 17 00:00:00 2001
From: Simon Pieters <zcorpan@gmail.com>
Date: Tue, 2 Mar 2021 21:07:09 +0100
Subject: [PATCH 081/105] Update tests/testdata (for <svg><p> in innerHTML)

---
 html5lib/tests/testdata | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/html5lib/tests/testdata b/html5lib/tests/testdata
index 71eebd59..082a4be9 160000
--- a/html5lib/tests/testdata
+++ b/html5lib/tests/testdata
@@ -1 +1 @@
-Subproject commit 71eebd59772d1d39aced0c0582ae9c09acf3ce6e
+Subproject commit 082a4be911f6bea27215038beb36ef7de822305b

From ad3bde76737e07b0369ac64c1dd2231e857e2baa Mon Sep 17 00:00:00 2001
From: Simon Pieters <zcorpan@gmail.com>
Date: Tue, 2 Mar 2021 21:45:49 +0100
Subject: [PATCH 082/105] Update html5lib's test expectations

---
 .pytest.expect | 96 +++++++++++++++++---------------------------------
 1 file changed, 32 insertions(+), 64 deletions(-)

diff --git a/.pytest.expect b/.pytest.expect
index 22cf51bb..d7fd6b44 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -33,14 +33,22 @@ u'html5lib/tests/testdata/tree-construction/blocks.dat::12::cElementTree::parser
 u'html5lib/tests/testdata/tree-construction/blocks.dat::12::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/blocks.dat::12::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/blocks.dat::12::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
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::0::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::ElementTree::parser::namespaced': FAIL
@@ -57,14 +65,6 @@ u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::cElementTr
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::1::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::ElementTree::parser::namespaced': FAIL
@@ -97,14 +97,6 @@ u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::cElementTr
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::ElementTree::parser::namespaced': FAIL
@@ -137,14 +129,6 @@ u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::cElementTr
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::38::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::ElementTree::parser::namespaced': FAIL
@@ -153,22 +137,6 @@ u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::cElementTr
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::40::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::ElementTree::parser::namespaced': FAIL
@@ -177,22 +145,22 @@ u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::cElementTr
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::47::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::48::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/isindex.dat::0::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/isindex.dat::0::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/isindex.dat::0::ElementTree::parser::namespaced': FAIL

From 2f25bf25f7db0ee7f0a86c53a2d949a0521f4757 Mon Sep 17 00:00:00 2001
From: James Addison <jay@jp-hosting.net>
Date: Wed, 19 May 2021 11:33:22 +0100
Subject: [PATCH 083/105] Add GitHub Actions workflow for tox (#527)

---
 .github/workflows/python-tox.yml | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 .github/workflows/python-tox.yml

diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml
new file mode 100644
index 00000000..ec5cf636
--- /dev/null
+++ b/.github/workflows/python-tox.yml
@@ -0,0 +1,21 @@
+on: [pull_request, push]
+jobs:
+  build:
+    # Prevent duplicate builds for 'internal' pull requests on existing commits
+    # Credit: https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012
+    if: github.event.push || github.event.pull_request.head.repo.full_name != github.repository
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python: [2.7, 3.5, 3.6, 3.7, 3.8, pypy-2.7, pypy3]
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          submodules: true
+      - uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python }}
+      - run: pip install tox
+      - run: tox -e py
+      - if: ${{ always() }}
+        run: python debug-info.py

From fefb7a15a6f4bec58372a6fecdfbe71294c0a6a1 Mon Sep 17 00:00:00 2001
From: Simon Pieters <zcorpan@gmail.com>
Date: Mon, 14 Jun 2021 16:12:43 +0200
Subject: [PATCH 084/105] Update tests/testdata (Test </p> and </br> in SVG)

---
 html5lib/tests/testdata | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/html5lib/tests/testdata b/html5lib/tests/testdata
index 082a4be9..9b4a29c9 160000
--- a/html5lib/tests/testdata
+++ b/html5lib/tests/testdata
@@ -1 +1 @@
-Subproject commit 082a4be911f6bea27215038beb36ef7de822305b
+Subproject commit 9b4a29c943b3c905e46b26569bae16de8b373516

From f7cab6f019ce94a1ec0192b6ff29aaebaf10b50d Mon Sep 17 00:00:00 2001
From: Simon Pieters <zcorpan@gmail.com>
Date: Mon, 14 Jun 2021 16:24:04 +0200
Subject: [PATCH 085/105] Update html5lib's test expectations

---
 .pytest.expect | 152 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 108 insertions(+), 44 deletions(-)

diff --git a/.pytest.expect b/.pytest.expect
index d7fd6b44..04eb436e 100644
--- a/.pytest.expect
+++ b/.pytest.expect
@@ -33,134 +33,166 @@ u'html5lib/tests/testdata/tree-construction/blocks.dat::12::cElementTree::parser
 u'html5lib/tests/testdata/tree-construction/blocks.dat::12::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/blocks.dat::12::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/blocks.dat::12::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::18::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::19::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::22::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::23::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::26::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::27::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::2::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::30::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::31::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::34::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::35::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::39::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::3::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::41::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::60::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::61::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::ElementTree::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::ElementTree::parser::void-namespace': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::cElementTree::parser::namespaced': FAIL
-u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::62::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::63::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::64::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/foreign-fragment.dat::66::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/isindex.dat::0::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/isindex.dat::0::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/isindex.dat::0::ElementTree::parser::namespaced': FAIL
@@ -1257,6 +1289,38 @@ u'html5lib/tests/testdata/tree-construction/tests25.dat::7::cElementTree::parser
 u'html5lib/tests/testdata/tree-construction/tests25.dat::7::cElementTree::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/tests25.dat::7::lxml::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/tests25.dat::7::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::16::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::17::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::18::lxml::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::DOM::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::DOM::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::ElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::ElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::cElementTree::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::cElementTree::parser::void-namespace': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::lxml::parser::namespaced': FAIL
+u'html5lib/tests/testdata/tree-construction/tests26.dat::19::lxml::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/tests8.dat::5::DOM::parser::namespaced': FAIL
 u'html5lib/tests/testdata/tree-construction/tests8.dat::5::DOM::parser::void-namespace': FAIL
 u'html5lib/tests/testdata/tree-construction/tests8.dat::5::ElementTree::parser::namespaced': FAIL

From 3ecbda615f7dbb73a5aa7c3af151b78b6ef3ec4b Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <hugovk@users.noreply.github.com>
Date: Wed, 1 Mar 2023 14:52:49 +0200
Subject: [PATCH 086/105] Bump Flake8 to fix CI for Python 3.7 (#554)

---
 html5lib/_inputstream.py          | 2 +-
 html5lib/serializer.py            | 4 ++--
 html5lib/tests/test_serializer.py | 2 +-
 html5lib/treebuilders/etree.py    | 4 ++--
 html5lib/treewalkers/etree.py     | 2 +-
 requirements-test.txt             | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py
index 0207dd21..a93b5a4e 100644
--- a/html5lib/_inputstream.py
+++ b/html5lib/_inputstream.py
@@ -324,7 +324,7 @@ def charsUntil(self, characters, opposite=False):
         except KeyError:
             if __debug__:
                 for c in characters:
-                    assert(ord(c) < 128)
+                    assert ord(c) < 128
             regex = "".join(["\\x%02x" % ord(c) for c in characters])
             if not opposite:
                 regex = "^%s" % regex
diff --git a/html5lib/serializer.py b/html5lib/serializer.py
index c66df683..a171ac1c 100644
--- a/html5lib/serializer.py
+++ b/html5lib/serializer.py
@@ -222,14 +222,14 @@ def __init__(self, **kwargs):
         self.strict = False
 
     def encode(self, string):
-        assert(isinstance(string, text_type))
+        assert isinstance(string, text_type)
         if self.encoding:
             return string.encode(self.encoding, "htmlentityreplace")
         else:
             return string
 
     def encodeStrict(self, string):
-        assert(isinstance(string, text_type))
+        assert isinstance(string, text_type)
         if self.encoding:
             return string.encode(self.encoding, "strict")
         else:
diff --git a/html5lib/tests/test_serializer.py b/html5lib/tests/test_serializer.py
index bce62459..a2be0be5 100644
--- a/html5lib/tests/test_serializer.py
+++ b/html5lib/tests/test_serializer.py
@@ -74,7 +74,7 @@ def _convertAttrib(self, attribs):
         attrs = {}
         for attrib in attribs:
             name = (attrib["namespace"], attrib["name"])
-            assert(name not in attrs)
+            assert name not in attrs
             attrs[name] = attrib["value"]
         return attrs
 
diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py
index 086bed4e..0b745081 100644
--- a/html5lib/treebuilders/etree.py
+++ b/html5lib/treebuilders/etree.py
@@ -108,7 +108,7 @@ def removeChild(self, node):
             node.parent = None
 
         def insertText(self, data, insertBefore=None):
-            if not(len(self._element)):
+            if not len(self._element):
                 if not self._element.text:
                     self._element.text = ""
                 self._element.text += data
@@ -201,7 +201,7 @@ def testSerializer(element):
         rv = []
 
         def serializeElement(element, indent=0):
-            if not(hasattr(element, "tag")):
+            if not hasattr(element, "tag"):
                 element = element.getroot()
             if element.tag == "<!DOCTYPE>":
                 if element.get("publicId") or element.get("systemId"):
diff --git a/html5lib/treewalkers/etree.py b/html5lib/treewalkers/etree.py
index 44653372..411a1d45 100644
--- a/html5lib/treewalkers/etree.py
+++ b/html5lib/treewalkers/etree.py
@@ -37,7 +37,7 @@ def getNodeDetails(self, node):
                 else:
                     node = elt
 
-            if not(hasattr(node, "tag")):
+            if not hasattr(node, "tag"):
                 node = node.getroot()
 
             if node.tag in ("DOCUMENT_ROOT", "DOCUMENT_FRAGMENT"):
diff --git a/requirements-test.txt b/requirements-test.txt
index 57f8f617..8c0ca7c7 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,7 +1,7 @@
 -r requirements.txt
 
 tox>=3.15.1,<4
-flake8>=3.8.1,<3.9
+flake8>=3.8.1,<6
 pytest>=4.6.10,<5 ; python_version < '3'
 pytest>=5.4.2,<7 ; python_version >= '3'
 coverage>=5.1,<6

From 10b7eb83b7d957033b8350eb354bf0e37c8c1746 Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <hugovk@users.noreply.github.com>
Date: Wed, 1 Mar 2023 14:53:31 +0200
Subject: [PATCH 087/105] Add support for Python 3.9 and 3.10 and 3.11 (#542)

---
 .appveyor.yml                    | 6 +++++-
 .github/workflows/python-tox.yml | 9 ++++++---
 .travis.yml                      | 3 ++-
 CHANGES.rst                      | 2 +-
 README.rst                       | 2 +-
 setup.py                         | 3 +++
 tox.ini                          | 4 ++--
 7 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index a1a3e347..8af60b9b 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,4 +1,4 @@
-# To activate, change the Appveyor settings to use `.appveyor.yml`.
+image: Visual Studio 2019
 environment:
   global:
     PATH: "C:\\Python27\\Scripts\\;%PATH%"
@@ -13,6 +13,10 @@ environment:
     - TOXENV: py37-optional
     - TOXENV: py38-base
     - TOXENV: py38-optional
+    - TOXENV: py39-base
+    - TOXENV: py39-optional
+    - TOXENV: py310-base
+    - TOXENV: py310-optional
 
 install:
   - git submodule update --init --recursive
diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml
index ec5cf636..78f7fdc3 100644
--- a/.github/workflows/python-tox.yml
+++ b/.github/workflows/python-tox.yml
@@ -6,15 +6,18 @@ jobs:
     if: github.event.push || github.event.pull_request.head.repo.full_name != github.repository
     runs-on: ubuntu-latest
     strategy:
+      fail-fast: false
       matrix:
-        python: [2.7, 3.5, 3.6, 3.7, 3.8, pypy-2.7, pypy3]
+        python: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-2.7", "pypy-3.8"]
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
         with:
           submodules: true
-      - uses: actions/setup-python@v2
+      - uses: actions/setup-python@v4
         with:
           python-version: ${{ matrix.python }}
+          cache: pip
+          cache-dependency-path: "requirements*.txt"
       - run: pip install tox
       - run: tox -e py
       - if: ${{ always() }}
diff --git a/.travis.yml b/.travis.yml
index d2d9e30e..780df9a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,12 +2,13 @@ language: python
 python:
   - "pypy3"
   - "pypy"
+  - "3.10"
+  - "3.9"
   - "3.8"
   - "3.7"
   - "3.6"
   - "3.5"
   - "2.7"
-  - "3.9-dev"
 
 cache: pip
 
diff --git a/CHANGES.rst b/CHANGES.rst
index 0f6314aa..3ed63a96 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -95,7 +95,7 @@ Released on July 14, 2016
   tested, doesn't entirely work, and as far as I can tell is
   completely unused by anyone.**
 
-* Move testsuite to ``py.test``.
+* Move testsuite to ``pytest``.
 
 * **Fix #124: move to webencodings for decoding the input byte stream;
   this makes html5lib compliant with the Encoding Standard, and
diff --git a/README.rst b/README.rst
index d367905d..072861ab 100644
--- a/README.rst
+++ b/README.rst
@@ -128,7 +128,7 @@ Tests
 -----
 
 Unit tests require the ``pytest`` and ``mock`` libraries and can be
-run using the ``py.test`` command in the root directory.
+run using the ``pytest`` command in the root directory.
 
 Test data are contained in a separate `html5lib-tests
 <https://github.com/html5lib/html5lib-tests>`_ repository and included
diff --git a/setup.py b/setup.py
index f84c1284..b4c11811 100644
--- a/setup.py
+++ b/setup.py
@@ -70,6 +70,9 @@ def default_environment():
     'Programming Language :: Python :: 3.6',
     'Programming Language :: Python :: 3.7',
     'Programming Language :: Python :: 3.8',
+    'Programming Language :: Python :: 3.9',
+    'Programming Language :: Python :: 3.10',
+    'Programming Language :: Python :: 3.11',
     'Programming Language :: Python :: Implementation :: CPython',
     'Programming Language :: Python :: Implementation :: PyPy',
     'Topic :: Software Development :: Libraries :: Python Modules',
diff --git a/tox.ini b/tox.ini
index 16b8cf41..42790f48 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py{27,35,36,37,38,py,py3}-{base,six19,optional}
+envlist = py{27,35,36,37,38,39,310,311,py,py3}-{base,six19,optional}
 
 [testenv]
 deps =
@@ -12,7 +12,7 @@ passenv =
   COVERAGE_RUN_OPTIONS
 commands =
   six19: pip install six==1.9
-  {env:PYTEST_COMMAND:{envbindir}/py.test} {posargs}
+  {env:PYTEST_COMMAND:{envbindir}/pytest} {posargs}
   flake8 {toxinidir}
 
 [testenv:doc]

From d1dfa20ecd28d09a01b027fc24675132a8196ed3 Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <hugovk@users.noreply.github.com>
Date: Wed, 1 Mar 2023 16:49:07 +0200
Subject: [PATCH 088/105] Remove Travis CI in favour of GitHub Actions (#545)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 .github/workflows/python-tox.yml |  2 +-
 .travis.yml                      | 26 --------------------------
 CONTRIBUTING.rst                 |  2 +-
 README.rst                       |  5 ++---
 4 files changed, 4 insertions(+), 31 deletions(-)
 delete mode 100644 .travis.yml

diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml
index 78f7fdc3..0e3e46db 100644
--- a/.github/workflows/python-tox.yml
+++ b/.github/workflows/python-tox.yml
@@ -8,7 +8,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-2.7", "pypy-3.8"]
+        python: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-2.7", "pypy-3.8"]
     steps:
       - uses: actions/checkout@v3
         with:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 780df9a2..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-language: python
-python:
-  - "pypy3"
-  - "pypy"
-  - "3.10"
-  - "3.9"
-  - "3.8"
-  - "3.7"
-  - "3.6"
-  - "3.5"
-  - "2.7"
-
-cache: pip
-
-env:
-  global:
-    - TOXENV=base,optional,six19-optional
-
-install:
-  - pip install tox
-
-script:
-  - tox
-
-after_script:
-  - python debug-info.py
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 8c5e1985..dba35216 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -16,7 +16,7 @@ documentation. Some useful information:
 - We keep the master branch passing all tests at all times on all
   supported versions.
 
-`Travis CI <https://travis-ci.org/html5lib/html5lib-python/>`_ is run
+`GitHub Actions <https://github.com/html5lib/html5lib-python/actions>`_ is run
 against all pull requests and should enforce all of the above.
 
 We use `Opera Critic <https://critic.hoppipolla.co.uk/>`_ as an external
diff --git a/README.rst b/README.rst
index 072861ab..39ae0afc 100644
--- a/README.rst
+++ b/README.rst
@@ -1,9 +1,8 @@
 html5lib
 ========
 
-.. image:: https://travis-ci.org/html5lib/html5lib-python.svg?branch=master
-    :target: https://travis-ci.org/html5lib/html5lib-python
-
+.. image:: https://github.com/html5lib/html5lib-python/actions/workflows/python-tox.yml/badge.svg
+    :target: https://github.com/html5lib/html5lib-python/actions/workflows/python-tox.yml
 
 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 6815a541f414cbd30e80f78841e4a72113c71910 Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <hugovk@users.noreply.github.com>
Date: Wed, 1 Mar 2023 16:50:06 +0200
Subject: [PATCH 089/105] Fix pytest warnings (#544)

---
 html5lib/tests/test_sanitizer.py | 7 ++++++-
 pytest.ini                       | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index f3faeb80..6ad43a3a 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -1,9 +1,14 @@
 from __future__ import absolute_import, division, unicode_literals
 
+import warnings
+
 import pytest
 
 from html5lib import constants, parseFragment, serialize
-from html5lib.filters import sanitizer
+
+with warnings.catch_warnings():
+    warnings.simplefilter("ignore", DeprecationWarning)
+    from html5lib.filters import sanitizer
 
 
 def sanitize_html(stream):
diff --git a/pytest.ini b/pytest.ini
index 8824977a..1f620d98 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,6 +1,6 @@
 [pytest]
 # Output fails, errors, xpass, and warnings; ignore doctest; make warnings errors
-addopts = -rfEXw -p no:doctest --strict
+addopts = -rfEXw -p no:doctest --strict-markers
 
 # Make xpass results be considered fail
 xfail_strict = true

From 5decf471b22db9aacb212bc22bfe74e1e0f67c60 Mon Sep 17 00:00:00 2001
From: Drew Hintz <pushespretn@gmail.com>
Date: Wed, 1 Mar 2023 06:50:48 -0800
Subject: [PATCH 090/105] remove redundant list comprehension (#547)

any() accepts a generator. This will cause it to run faster because the any() returns as soon as it finds a True value.
---
 html5lib/html5parser.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 74d829d9..9fb038b7 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -1002,8 +1002,8 @@ def processCharacters(self, token):
             self.tree.insertText(token["data"])
             # This must be bad for performance
             if (self.parser.framesetOK and
-                any([char not in spaceCharacters
-                     for char in token["data"]])):
+                any(char not in spaceCharacters
+                    for char in token["data"])):
                 self.parser.framesetOK = False
 
         def processSpaceCharactersNonPre(self, token):
@@ -1850,7 +1850,7 @@ def __init__(self, *args, **kwargs):
 
         def flushCharacters(self):
             data = "".join([item["data"] for item in self.characterTokens])
-            if any([item not in spaceCharacters for item in data]):
+            if any(item not in spaceCharacters for item in data):
                 token = {"type": tokenTypes["Characters"], "data": data}
                 self.parser.phases["inTable"].insertText(token)
             elif data:

From 1cd57cb0a55890b5b114a945fe861a23b9ede309 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= <philip@foolip.org>
Date: Wed, 1 Mar 2023 16:26:55 +0100
Subject: [PATCH 091/105] Replace os.path.split with .dirname or .basename in
 two places (#508)

---
 html5lib/tests/support.py         | 2 +-
 html5lib/tests/tokenizertotree.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/html5lib/tests/support.py b/html5lib/tests/support.py
index 9cd5afbe..1bd0ccc1 100644
--- a/html5lib/tests/support.py
+++ b/html5lib/tests/support.py
@@ -8,7 +8,7 @@
 import glob
 import xml.sax.handler
 
-base_path = os.path.split(__file__)[0]
+base_path = os.path.dirname(__file__)
 
 test_dir = os.path.join(base_path, 'testdata')
 sys.path.insert(0, os.path.abspath(os.path.join(base_path,
diff --git a/html5lib/tests/tokenizertotree.py b/html5lib/tests/tokenizertotree.py
index 8528e876..42463f32 100644
--- a/html5lib/tests/tokenizertotree.py
+++ b/html5lib/tests/tokenizertotree.py
@@ -29,7 +29,7 @@ def run_file(filename, out_path):
     except ValueError:
         sys.stderr.write("Failed to load %s\n" % filename)
         return
-    name = os.path.splitext(os.path.split(filename)[1])[0]
+    name = os.path.splitext(os.path.basename(filename))[0]
     output_file = open(os.path.join(out_path, "tokenizer_%s.dat" % name), "w")
 
     if 'tests' in tests_data:

From 2f64f3bc408cc3b000e85f756963d57158cedecd Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <hugovk@users.noreply.github.com>
Date: Wed, 1 Mar 2023 18:17:27 +0200
Subject: [PATCH 092/105] README: Replace broken mailing list link with archive
 (#543)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 README.rst | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/README.rst b/README.rst
index 39ae0afc..a17411ab 100644
--- a/README.rst
+++ b/README.rst
@@ -144,7 +144,9 @@ which can be found on PyPI.
 Questions?
 ----------
 
-There's a mailing list available for support on Google Groups,
-`html5lib-discuss <http://groups.google.com/group/html5lib-discuss>`_,
-though you may get a quicker response asking on IRC in `#whatwg on
-irc.freenode.net <http://wiki.whatwg.org/wiki/IRC>`_.
+Check out `the docs https://html5lib.readthedocs.io/en/latest/`_. Still
+need help? Go to our `GitHub Discussions
+https://github.com/html5lib/html5lib-python/discussions`_.
+
+You can also browse the archives of the `html5lib-discuss mailing list 
+https://www.mail-archive.com/html5lib-discuss@googlegroups.com/`_.

From 4f9f5bfe13d5389fdb8905349a6405c1c3b1e8b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Langa?= <lukasz@langa.pl>
Date: Wed, 1 Mar 2023 17:48:03 +0100
Subject: [PATCH 093/105] Fix ReST link markup in README

---
 README.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.rst b/README.rst
index a17411ab..6a623a43 100644
--- a/README.rst
+++ b/README.rst
@@ -144,9 +144,9 @@ which can be found on PyPI.
 Questions?
 ----------
 
-Check out `the docs https://html5lib.readthedocs.io/en/latest/`_. Still
+Check out `the docs <https://html5lib.readthedocs.io/en/latest/>`_. Still
 need help? Go to our `GitHub Discussions
-https://github.com/html5lib/html5lib-python/discussions`_.
+<https://github.com/html5lib/html5lib-python/discussions>`_.
 
 You can also browse the archives of the `html5lib-discuss mailing list 
-https://www.mail-archive.com/html5lib-discuss@googlegroups.com/`_.
+<https://www.mail-archive.com/html5lib-discuss@googlegroups.com/>`_.

From 1b393775e62b0fed8ba7e713b09e1b2713f63b1c Mon Sep 17 00:00:00 2001
From: anonymous <29055749+idiomaticrefactoring@users.noreply.github.com>
Date: Thu, 2 Mar 2023 01:05:27 +0800
Subject: [PATCH 094/105] Use for:else: where it makes sense (#539)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: zzj <29055749+zjzh@users.noreply.github.com>
Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 html5lib/_ihatexml.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/html5lib/_ihatexml.py b/html5lib/_ihatexml.py
index 3ff803c1..d725eabd 100644
--- a/html5lib/_ihatexml.py
+++ b/html5lib/_ihatexml.py
@@ -104,18 +104,15 @@ def charStringToList(chars):
     charRanges = [item.strip() for item in chars.split(" | ")]
     rv = []
     for item in charRanges:
-        foundMatch = False
         for regexp in (reChar, reCharRange):
             match = regexp.match(item)
             if match is not None:
                 rv.append([hexToInt(item) for item in match.groups()])
                 if len(rv[-1]) == 1:
                     rv[-1] = rv[-1] * 2
-                foundMatch = True
                 break
-        if not foundMatch:
+        else:
             assert len(item) == 1
-
             rv.append([ord(item)] * 2)
     rv = normaliseCharList(rv)
     return rv

From c64a1115daa463c7c60b32104e07f37c26b8a097 Mon Sep 17 00:00:00 2001
From: theRealProHacker <77074862+theRealProHacker@users.noreply.github.com>
Date: Wed, 1 Mar 2023 21:02:42 +0100
Subject: [PATCH 095/105] Restore ability to provide a tree builder name as
 string (#559)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 html5lib/html5parser.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 9fb038b7..4c2d4c75 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -115,6 +115,9 @@ def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=Fa
 
         if tree is None:
             tree = treebuilders.getTreeBuilder("etree")
+        elif isinstance(tree, str):
+            tree = treebuilders.getTreeBuilder(tree)
+
         self.tree = tree(namespaceHTMLElements)
         self.errors = []
 

From ff7fa3721e1072898e91531a52e6befefd9fbc55 Mon Sep 17 00:00:00 2001
From: Tom Most <twm@freecog.net>
Date: Wed, 1 Mar 2023 13:55:52 -0800
Subject: [PATCH 096/105] Sanitizer: Allow <summary> (#423)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add tests that the sanitizer allows <details open> and <summary> and
update the implementation to allow <summary>.

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 CHANGES.rst                      |  8 +++++++-
 html5lib/filters/sanitizer.py    |  1 +
 html5lib/tests/test_sanitizer.py | 12 ++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 3ed63a96..f28caa86 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,13 @@
 Change Log
 ----------
 
+1.2
+~~~
+
+Bug fixes:
+
+* The sanitizer now permits ``<summary>`` tags.
+
 1.1
 ~~~
 
@@ -22,7 +29,6 @@ Other changes:
   ``html5lib`` keeps working in future Python versions. (#403)
 * Drop optional ``datrie`` dependency. (#442)
 
-
 1.0.1
 ~~~~~
 
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index 70ef9066..684f2172 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -113,6 +113,7 @@
     (namespaces['html'], 'strike'),
     (namespaces['html'], 'strong'),
     (namespaces['html'], 'sub'),
+    (namespaces['html'], 'summary'),
     (namespaces['html'], 'sup'),
     (namespaces['html'], 'table'),
     (namespaces['html'], 'tbody'),
diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index 6ad43a3a..9deed6f5 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -111,6 +111,18 @@ def param_sanitizer():
                """<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
 
 
+def test_details_open_allowed():
+    sanitized = sanitize_html("<details open>.</details>")
+    expected = '<details open>.</details>'
+    assert expected == sanitized
+
+
+def test_details_summary_allowed():
+    sanitized = sanitize_html("<details><summary>.</summary><p>...</p></details>")
+    expected = '<details><summary>.</summary><p>...</p></details>'
+    assert expected == sanitized
+
+
 @pytest.mark.parametrize("expected, input",
                          (pytest.param(expected, input, id=id)
                           for id, expected, input in param_sanitizer()))

From 5c30ac35aa51f69c7048dc701d6f9210269b5abc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Langa?= <lukasz@langa.pl>
Date: Wed, 1 Mar 2023 23:06:02 +0100
Subject: [PATCH 097/105] Fix reference targets in Sphinx documentation (#562)

Fixes #548
---
 doc/conf.py                   | 10 +++++++++-
 doc/html5lib.filters.rst      | 33 +++++++++++++++++++--------------
 doc/html5lib.rst              | 17 +++++++++++------
 doc/html5lib.treeadapters.rst |  3 ---
 doc/html5lib.treebuilders.rst | 19 ++++++++-----------
 doc/html5lib.treewalkers.rst  | 23 ++++++++++-------------
 doc/movingparts.rst           |  6 +++---
 html5lib/treebuilders/base.py |  1 +
 8 files changed, 61 insertions(+), 51 deletions(-)

diff --git a/doc/conf.py b/doc/conf.py
index 22ebab4f..d5a1e863 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -19,7 +19,8 @@
 
 # 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']
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.viewcode',
+              'sphinx.ext.intersphinx']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
@@ -92,6 +93,13 @@
 ]
 
 
+intersphinx_mapping = {
+    'python': ('https://docs.python.org/3/', None),
+    'lxml': ('https://lxml.de/apidoc/', None),
+    'chardet': ('https://chardet.readthedocs.io/en/latest/', None),
+}
+
+
 class CExtMock(object):
     """Required for autodoc on readthedocs.org where you cannot build C extensions."""
     def __init__(self, *args, **kwargs):
diff --git a/doc/html5lib.filters.rst b/doc/html5lib.filters.rst
index d70e4552..89a5bc7b 100644
--- a/doc/html5lib.filters.rst
+++ b/doc/html5lib.filters.rst
@@ -1,56 +1,61 @@
 filters Package
 ===============
 
-:mod:`base` Module
--------------------
+``base`` Module
+----------------
 
 .. automodule:: html5lib.filters.base
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`alphabeticalattributes` Module
-------------------------------------
+.. autoclass:: html5lib.filters.base.Filter
+    :members:
+    :show-inheritance:
+    :special-members: __init__
+
+``alphabeticalattributes`` Module
+---------------------------------
 
 .. automodule:: html5lib.filters.alphabeticalattributes
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`inject_meta_charset` Module
----------------------------------
+``inject_meta_charset`` Module
+------------------------------
 
 .. automodule:: html5lib.filters.inject_meta_charset
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`lint` Module
-------------------
+``lint`` Module
+---------------
 
 .. automodule:: html5lib.filters.lint
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`optionaltags` Module
---------------------------
+``optionaltags`` Module
+-----------------------
 
 .. automodule:: html5lib.filters.optionaltags
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`sanitizer` Module
------------------------
+``sanitizer`` Module
+--------------------
 
 .. automodule:: html5lib.filters.sanitizer
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`whitespace` Module
-------------------------
+``whitespace`` Module
+---------------------
 
 .. automodule:: html5lib.filters.whitespace
     :members:
diff --git a/doc/html5lib.rst b/doc/html5lib.rst
index d7c75c58..57d1db54 100644
--- a/doc/html5lib.rst
+++ b/doc/html5lib.rst
@@ -4,29 +4,34 @@ html5lib Package
 .. automodule:: html5lib
     :members: __version__
 
-:mod:`constants` Module
------------------------
+``constants`` Module
+--------------------
 
 .. automodule:: html5lib.constants
     :members:
     :show-inheritance:
 
-:mod:`html5parser` Module
--------------------------
+``html5parser`` Module
+----------------------
 
 .. automodule:: html5lib.html5parser
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`serializer` Module
-------------------------
+``serializer`` Module
+---------------------
 
 .. automodule:: html5lib.serializer
     :members:
     :show-inheritance:
     :special-members: __init__
 
+.. autoclass:: html5lib.serializer.HTMLSerializer
+    :members:
+    :show-inheritance:
+    :special-members: __init__
+
 Subpackages
 -----------
 
diff --git a/doc/html5lib.treeadapters.rst b/doc/html5lib.treeadapters.rst
index 1d3a9fba..d20c1e95 100644
--- a/doc/html5lib.treeadapters.rst
+++ b/doc/html5lib.treeadapters.rst
@@ -1,9 +1,6 @@
 treeadapters Package
 ====================
 
-:mod:`~html5lib.treeadapters` Package
--------------------------------------
-
 .. automodule:: html5lib.treeadapters
     :members:
     :show-inheritance:
diff --git a/doc/html5lib.treebuilders.rst b/doc/html5lib.treebuilders.rst
index 1a051e50..507d319e 100644
--- a/doc/html5lib.treebuilders.rst
+++ b/doc/html5lib.treebuilders.rst
@@ -1,40 +1,37 @@
 treebuilders Package
 ====================
 
-:mod:`treebuilders` Package
----------------------------
-
 .. automodule:: html5lib.treebuilders
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`base` Module
--------------------
+``base`` Module
+---------------
 
 .. automodule:: html5lib.treebuilders.base
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`dom` Module
------------------
+``dom`` Module
+--------------
 
 .. automodule:: html5lib.treebuilders.dom
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`etree` Module
--------------------
+``etree`` Module
+----------------
 
 .. automodule:: html5lib.treebuilders.etree
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`etree_lxml` Module
-------------------------
+``etree_lxml`` Module
+---------------------
 
 .. automodule:: html5lib.treebuilders.etree_lxml
     :members:
diff --git a/doc/html5lib.treewalkers.rst b/doc/html5lib.treewalkers.rst
index 4afef476..53bd5c31 100644
--- a/doc/html5lib.treewalkers.rst
+++ b/doc/html5lib.treewalkers.rst
@@ -1,48 +1,45 @@
 treewalkers Package
 ===================
 
-:mod:`treewalkers` Package
---------------------------
-
 .. automodule:: html5lib.treewalkers
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`base` Module
-------------------
+``base`` Module
+---------------
 
 .. automodule:: html5lib.treewalkers.base
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`dom` Module
------------------
+``dom`` Module
+--------------
 
 .. automodule:: html5lib.treewalkers.dom
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`etree` Module
--------------------
+``etree`` Module
+----------------
 
 .. automodule:: html5lib.treewalkers.etree
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`etree_lxml` Module
-------------------------
+``etree_lxml`` Module
+---------------------
 
 .. automodule:: html5lib.treewalkers.etree_lxml
     :members:
     :show-inheritance:
     :special-members: __init__
 
-:mod:`genshi` Module
---------------------
+``genshi`` Module
+-----------------
 
 .. automodule:: html5lib.treewalkers.genshi
     :members:
diff --git a/doc/movingparts.rst b/doc/movingparts.rst
index 6ba367a2..c7fe0247 100644
--- a/doc/movingparts.rst
+++ b/doc/movingparts.rst
@@ -15,9 +15,9 @@ Tree builders
 The parser reads HTML by tokenizing the content and building a tree that
 the user can later access. html5lib can build three types of trees:
 
-* ``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.
+* ``etree`` - this is the default; builds a tree based on
+  :mod:`xml.etree.ElementTree`, 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 :mod:`xml.dom.minidom`.
diff --git a/html5lib/treebuilders/base.py b/html5lib/treebuilders/base.py
index e4a3d710..020d7e15 100644
--- a/html5lib/treebuilders/base.py
+++ b/html5lib/treebuilders/base.py
@@ -121,6 +121,7 @@ def hasContent(self):
 
 class ActiveFormattingElements(list):
     def append(self, node):
+        """Append node to the end of the list."""
         equalCount = 0
         if node != Marker:
             for element in self[::-1]:

From 6ca02445937a6a7c930c262d1325ec15fdb0324a Mon Sep 17 00:00:00 2001
From: Tom Most <twm@freecog.net>
Date: Thu, 2 Mar 2023 06:22:38 -0800
Subject: [PATCH 098/105] Support the <wbr> element (#395)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 CHANGES.rst                      | 10 ++++++++++
 html5lib/constants.py            |  3 ++-
 html5lib/filters/sanitizer.py    |  1 +
 html5lib/tests/test_sanitizer.py |  6 ++++++
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index f28caa86..cf95ea0b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,14 @@ Change Log
 1.2
 ~~~
 
+Unreleased yet
+
+Features:
+
+* Add support for the ``<wbr>`` element in the sanitizer, `which indicates
+  a line break opportunity <https://html.spec.whatwg.org/#the-wbr-element>`_.
+  This element is allowed by default. (#395) (Thank you, Tom Most!)
+
 Bug fixes:
 
 * The sanitizer now permits ``<summary>`` tags.
@@ -11,6 +19,8 @@ Bug fixes:
 1.1
 ~~~
 
+Released on June 23, 2020
+
 Breaking changes:
 
 * Drop support for Python 3.3. (#358)
diff --git a/html5lib/constants.py b/html5lib/constants.py
index fe3e237c..11184e0d 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -571,7 +571,8 @@
     "col",
     "input",
     "source",
-    "track"
+    "track",
+    "wbr",
 ])
 
 cdataElements = frozenset(['title', 'textarea'])
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index 684f2172..f7ac8d9b 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -129,6 +129,7 @@
     (namespaces['html'], 'ul'),
     (namespaces['html'], 'var'),
     (namespaces['html'], 'video'),
+    (namespaces['html'], 'wbr'),
     (namespaces['mathml'], 'maction'),
     (namespaces['mathml'], 'math'),
     (namespaces['mathml'], 'merror'),
diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index 9deed6f5..a6cbd798 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -55,6 +55,12 @@ def test_data_uri_disallowed_type():
     assert expected == sanitized
 
 
+def test_wbr_allowed():
+    sanitized = sanitize_html('<wbr>')
+    expected = '<wbr/>'
+    assert expected == sanitized
+
+
 def param_sanitizer():
     for ns, tag_name in sanitizer.allowed_elements:
         if ns != constants.namespaces["html"]:

From 82047b0e8506886255c5cca5954c870f84e3adda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Langa?= <lukasz@langa.pl>
Date: Thu, 2 Mar 2023 20:42:35 +0100
Subject: [PATCH 099/105] Sort void elements alphabetically, document ones that
 don't match current standard (#563)

---
 html5lib/constants.py | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/html5lib/constants.py b/html5lib/constants.py
index 11184e0d..e83bfb5d 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -557,24 +557,36 @@
 )
 
 voidElements = frozenset([
+    "area",
     "base",
-    "command",
-    "event-source",
-    "link",
-    "meta",
-    "hr",
     "br",
-    "img",
-    "embed",
-    "param",
-    "area",
     "col",
+    "command",  # removed ^1
+    "embed",
+    "event-source",  # renamed and later removed ^2
+    "hr",
+    "img",
     "input",
+    "link",
+    "meta",
+    "param",  # deprecated ^3
     "source",
     "track",
     "wbr",
 ])
 
+# Removals and deprecations in the HTML 5 spec:
+# ^1: command
+#     http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-December/038472.html
+#     https://github.com/whatwg/html/commit/9e2e25f4ae90969a7c64e0763c98548a35b50af8
+# ^2: event-source
+#     renamed to eventsource in 7/2008:
+#     https://github.com/whatwg/html/commit/d157945d0285b4463a04b57318da0c4b300a99e7
+#     removed entirely in 2/2009:
+#     https://github.com/whatwg/html/commit/43cbdbfbb7eb74b0d65e0f4caab2020c0b2a16ff
+# ^3: param
+#     https://developer.mozilla.org/en-US/docs/Web/HTML/Element/param
+
 cdataElements = frozenset(['title', 'textarea'])
 
 rcdataElements = frozenset([

From 01b7dea9a378d69ae66767183a42e602d7a468cd Mon Sep 17 00:00:00 2001
From: Tom Most <twm@freecog.net>
Date: Fri, 3 Mar 2023 01:06:08 -0800
Subject: [PATCH 100/105] Add support for <ol reversed>, related attributes
 (#396)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Mark <ol reversed> as a boolean attribute so it serializes properly in
  HTML.
* Allow <ol reversed> in the sanitizer. Closes #321.
* Allow <ol start> in the sanitizer.
* <ol type> was already allowed, but probably accidentally (type is an
  attribute allowed for other tags). I added a test to prevent it from
  regressing in case we add per-element attribute sanitization in the
  future.

https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-reversed

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 CHANGES.rst                      |  7 ++++++-
 html5lib/constants.py            |  1 +
 html5lib/filters/sanitizer.py    |  2 ++
 html5lib/tests/test_sanitizer.py | 18 ++++++++++++++++++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index cf95ea0b..47dcda3a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -11,10 +11,15 @@ Features:
 * Add support for the ``<wbr>`` element in the sanitizer, `which indicates
   a line break opportunity <https://html.spec.whatwg.org/#the-wbr-element>`_.
   This element is allowed by default. (#395) (Thank you, Tom Most!)
+* Add support for serializing the ``<ol reversed>`` boolean attribute. (Thank
+  you, Tom Most!) (#396)
+* The ``<ol reversed>`` and ``<ol start>`` attributes are now permitted by the
+  sanitizer. (#321) (Thank you, Tom Most!)
 
 Bug fixes:
 
-* The sanitizer now permits ``<summary>`` tags.
+* The sanitizer now permits ``<summary>`` tags. It used to allow ``<details>``
+  already. (#423)
 
 1.1
 ~~~
diff --git a/html5lib/constants.py b/html5lib/constants.py
index e83bfb5d..2fa4146d 100644
--- a/html5lib/constants.py
+++ b/html5lib/constants.py
@@ -617,6 +617,7 @@
     "button": frozenset(["disabled", "autofocus"]),
     "input": frozenset(["disabled", "readonly", "required", "autofocus", "checked", "ismap"]),
     "select": frozenset(["disabled", "readonly", "autofocus", "multiple"]),
+    "ol": frozenset(["reversed"]),
     "output": frozenset(["disabled", "readonly"]),
     "iframe": frozenset(["seamless"]),
 }
diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index f7ac8d9b..81c85d44 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -365,6 +365,7 @@
     (None, 'maxsize'),
     (None, 'minsize'),
     (None, 'other'),
+    (None, 'reversed'),
     (None, 'rowalign'),
     (None, 'rowalign'),
     (None, 'rowalign'),
@@ -375,6 +376,7 @@
     (None, 'scriptlevel'),
     (None, 'selection'),
     (None, 'separator'),
+    (None, 'start'),
     (None, 'stretchy'),
     (None, 'width'),
     (None, 'width'),
diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py
index a6cbd798..499310b6 100644
--- a/html5lib/tests/test_sanitizer.py
+++ b/html5lib/tests/test_sanitizer.py
@@ -154,3 +154,21 @@ def test_uppercase_color_codes_in_style():
     sanitized = sanitize_html("<p style=\"border: 1px solid #A2A2A2;\"></p>")
     expected = '<p style=\"border: 1px solid #A2A2A2;\"></p>'
     assert expected == sanitized
+
+
+def test_ol_start_allowed():
+    sanitized = sanitize_html("<ol start=2><li>.</ol>")
+    expected = '<ol start="2"><li>.</li></ol>'
+    assert expected == sanitized
+
+
+def test_ol_type_allowed():
+    sanitized = sanitize_html("<ol type=I><li>.</ol>")
+    expected = '<ol type="I"><li>.</li></ol>'
+    assert expected == sanitized
+
+
+def test_ol_reversed_allowed():
+    sanitized = sanitize_html("<ol reversed><li>.</ol>")
+    expected = '<ol reversed><li>.</li></ol>'
+    assert expected == sanitized

From f0bb2a639d768c5bd6640c020aef86621a63b02b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Langa?= <lukasz@langa.pl>
Date: Fri, 3 Mar 2023 15:50:22 +0100
Subject: [PATCH 101/105] Test more on GitHub Actions (#564)

The only environments left on AppVeyor are now 2.7, 3.5, and 3.6. The remaining Python versions are now also tested on Windows using GitHub Actions.

Additionally, a new group of dependencies called "oldest" is now tested as well to ensure compatibility with the oldest pinned versions in requirements.txt and setup.py.

AppVeyor is used for 3.5 and 3.6 because those versions aren't available on GitHub Actions at all. Python 2.7 crashes on Windows with a pip cache failure so it only runs on GHA with the "oldest" dependencies on Ubuntu.

The other Python version running "oldest" dependencies is 3.7, also only running on Ubuntu.
---
 .appveyor.yml                    |  8 -----
 .github/workflows/python-tox.yml | 51 +++++++++++++++++++++++++---
 requirements-install.sh          | 15 ---------
 requirements-oldest.txt          | 29 ++++++++++++++++
 requirements-optional.txt        |  6 ++--
 requirements-test.txt            |  4 +--
 setup.py                         | 12 +++----
 tox.ini                          |  7 ++--
 toxver.py                        | 57 ++++++++++++++++++++++++++++++++
 9 files changed, 147 insertions(+), 42 deletions(-)
 delete mode 100755 requirements-install.sh
 create mode 100644 requirements-oldest.txt
 create mode 100755 toxver.py

diff --git a/.appveyor.yml b/.appveyor.yml
index 8af60b9b..7661aa63 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -9,14 +9,6 @@ environment:
     - TOXENV: py35-optional
     - TOXENV: py36-base
     - TOXENV: py36-optional
-    - TOXENV: py37-base
-    - TOXENV: py37-optional
-    - TOXENV: py38-base
-    - TOXENV: py38-optional
-    - TOXENV: py39-base
-    - TOXENV: py39-optional
-    - TOXENV: py310-base
-    - TOXENV: py310-optional
 
 install:
   - git submodule update --init --recursive
diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml
index 0e3e46db..cfcc42e6 100644
--- a/.github/workflows/python-tox.yml
+++ b/.github/workflows/python-tox.yml
@@ -4,21 +4,62 @@ jobs:
     # Prevent duplicate builds for 'internal' pull requests on existing commits
     # Credit: https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012
     if: github.event.push || github.event.pull_request.head.repo.full_name != github.repository
-    runs-on: ubuntu-latest
     strategy:
       fail-fast: false
       matrix:
-        python: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy-2.7", "pypy-3.8"]
+        # 2.7, 3.5, and 3.6 run on Windows via AppVeyor
+        python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
+        os: [ubuntu-latest, windows-latest]
+        deps: [base, optional]
+        include:
+          - python: "pypy-2.7"
+            os: ubuntu-latest
+            deps: base
+          - python: "pypy-3.8"
+            os: ubuntu-latest
+            deps: base
+          - python: "2.7"
+            os: ubuntu-latest
+            deps: oldest
+          - python: "3.7"
+            os: ubuntu-latest
+            deps: oldest
+    runs-on: ${{ matrix.os }}
     steps:
       - uses: actions/checkout@v3
         with:
           submodules: true
-      - uses: actions/setup-python@v4
+      - if: ${{ matrix.deps == 'base' }}
+        uses: actions/setup-python@v4
         with:
           python-version: ${{ matrix.python }}
           cache: pip
-          cache-dependency-path: "requirements*.txt"
+          cache-dependency-path: |
+            requirements.txt
+            requirements-test.txt
+      - if: ${{ matrix.deps == 'optional' }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.python }}
+          cache: pip
+          cache-dependency-path: |
+            requirements.txt
+            requirements-optional.txt
+            requirements-test.txt
+      - if: ${{ matrix.deps == 'oldest' }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.python }}
+          cache: pip
+          cache-dependency-path: |
+            requirements-oldest.txt
+      - if: ${{ matrix.os == 'windows-latest' }}
+        name: Determine environment name for Tox (PowerShell)
+        run: python toxver.py ${{ matrix.python }} ${{ matrix.deps }} >> $env:GITHUB_ENV
+      - if: ${{ matrix.os == 'ubuntu-latest' }}
+        name: Determine environment name for Tox (Bash)
+        run: python toxver.py ${{ matrix.python }} ${{ matrix.deps }} >> $GITHUB_ENV
       - run: pip install tox
-      - run: tox -e py
+      - run: tox
       - if: ${{ always() }}
         run: python debug-info.py
diff --git a/requirements-install.sh b/requirements-install.sh
deleted file mode 100755
index b7a8d96d..00000000
--- a/requirements-install.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash -ex
-
-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 codecov
-fi
diff --git a/requirements-oldest.txt b/requirements-oldest.txt
new file mode 100644
index 00000000..68d0f13d
--- /dev/null
+++ b/requirements-oldest.txt
@@ -0,0 +1,29 @@
+# This allows us to install the actually oldest supported dependencies and test whether that works.
+
+# requirements.txt
+six==1.9
+webencodings==0.5.1
+
+# requirements-optional.txt
+genshi==0.7.1 ; python_version < '3.8'
+genshi==0.7.6 ; python_version >= '3.8'
+chardet==2.2.1
+# this should be 3.4.0 but there are no Linux
+# binary wheels for older releases 
+lxml==3.8.0 ; python_version < '3.7'
+# minimums for 3.x are actually different:
+# - 3.7 is actually 4.1.1
+# - 3.8 is actually 4.3.5
+# - 3.9-3.10 is actually 4.5.2
+# - 3.11 is actually 4.9.0
+lxml==4.9.0 ; python_version >= '3.7'
+
+# requirements-test.txt
+flake8==3.9.2 ; python_version < '3.6'
+flake8==5.0.4; python_version >= '3.6'
+pytest==4.6.10 ; python_version < '3'
+pytest==5.4.2 ; python_version >= '3'
+coverage==5.1
+pytest-expect==1.1.0
+mock==3.0.5 ; python_version < '3.6'
+mock==4.0.2 ; python_version >= '3.6'
\ No newline at end of file
diff --git a/requirements-optional.txt b/requirements-optional.txt
index 2e78c952..2e112e95 100644
--- a/requirements-optional.txt
+++ b/requirements-optional.txt
@@ -2,12 +2,12 @@
 
 # We support a Genshi treewalker that can be used to serialize Genshi
 # streams.
-genshi
+genshi>=0.7.1
 
 # chardet can be used as a fallback in case we are unable to determine
 # the encoding of a document.
-chardet>=2.2
+chardet>=2.2.1
 
 # lxml is supported with its own treebuilder ("lxml") and otherwise
 # uses the standard ElementTree support
-lxml ; platform_python_implementation == 'CPython'
+lxml>=3.4.0 ; platform_python_implementation == 'CPython'
diff --git a/requirements-test.txt b/requirements-test.txt
index 8c0ca7c7..27866e59 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,7 +1,7 @@
 -r requirements.txt
 
-tox>=3.15.1,<4
-flake8>=3.8.1,<6
+flake8==3.9.2 ; python_version < '3.6'
+flake8>=5.0.4; python_version >= '3.6'
 pytest>=4.6.10,<5 ; python_version < '3'
 pytest>=5.4.2,<7 ; python_version >= '3'
 coverage>=5.1,<6
diff --git a/setup.py b/setup.py
index b4c11811..30ee0575 100644
--- a/setup.py
+++ b/setup.py
@@ -108,23 +108,23 @@ def default_environment():
       packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
       install_requires=[
           'six>=1.9',
-          'webencodings',
+          'webencodings>=0.5.1',
       ],
       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.
-          "lxml:platform_python_implementation == 'CPython'": ["lxml"],
+          "lxml:platform_python_implementation == 'CPython'": ["lxml>=3.4.0"],
 
           # Standard extras, will be installed when the extra is requested.
-          "genshi": ["genshi"],
-          "chardet": ["chardet>=2.2"],
+          "genshi": ["genshi>=0.7.1"],
+          "chardet": ["chardet>=2.2.1"],
 
           # The all extra combines a standard extra which will be used anytime
           # the all extra is requested, and it extends it with a conditional
           # 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'": ["lxml"],
+          "all": ["genshi>=0.7.1", "chardet>=2.2.1"],
+          "all:platform_python_implementation == 'CPython'": ["lxml>=3.4.0"],
       },
       )
diff --git a/tox.ini b/tox.ini
index 42790f48..fb228e96 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,17 +1,18 @@
 [tox]
-envlist = py{27,35,36,37,38,39,310,311,py,py3}-{base,six19,optional}
+envlist = py{27,35,36,37,38,39,310,311,py,py3}-{base,optional,oldest}
 
 [testenv]
 deps =
+  base: -r{toxinidir}/requirements-test.txt
+  optional: -r{toxinidir}/requirements-test.txt
   optional: -r{toxinidir}/requirements-optional.txt
-  -r{toxinidir}/requirements-test.txt
+  oldest: -r{toxinidir}/requirements-oldest.txt
   doc: Sphinx
 
 passenv =
   PYTEST_COMMAND  # this is maintained so one can, e.g., PYTEST_COMMAND="coverage run -m pytest"
   COVERAGE_RUN_OPTIONS
 commands =
-  six19: pip install six==1.9
   {env:PYTEST_COMMAND:{envbindir}/pytest} {posargs}
   flake8 {toxinidir}
 
diff --git a/toxver.py b/toxver.py
new file mode 100755
index 00000000..68eb71ec
--- /dev/null
+++ b/toxver.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+"""
+usage: toxver.py [python-version] [deps]
+
+Returns a Tox environment name given a GHA matrix Python version and dependencies.
+Many GHA configurations do this with inline Bash scripts but we want our solution
+to be cross-platform and work on Windows workers, too.
+
+Examples:
+
+    $ toxver.py pypy-3.8 base
+    TOXENV=pypy3-base
+
+    $ toxver.py 2.7 oldest
+    TOXENV=py27-oldest
+
+    $ toxver.py ~3.12.0-0 optional
+    TOXENV=py312-optional
+
+"""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+import sys
+
+
+def main(argv):
+    if len(argv) != 3:
+        print(__doc__.strip(), file=sys.stderr)
+        return 1
+
+    deps = argv[2]
+
+    if argv[1].startswith("pypy-2"):
+        print("TOXENV=pypy-" + deps)
+        return 0
+
+    if argv[1].startswith("pypy-3"):
+        print("TOXENV=pypy3-" + deps)
+        return 0
+
+    if argv[1].startswith("~"):
+        ver = argv[1][1:5]
+    else:
+        ver = argv[1]
+
+    ver = ver.replace(".", "")
+    print("TOXENV=py" + ver + "-" + deps)
+    return 0
+
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv))

From 3e500bb6e4188ea087f5b743a720ed9f4d9216f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Langa?= <lukasz@langa.pl>
Date: Fri, 3 Mar 2023 16:43:58 +0100
Subject: [PATCH 102/105] Allow min-height, max-height, min-width, max-width in
 the sanitizer (#566)

Co-authored-by: Vladimir Kuvandjiev <vladimir.kuvandjiev@endava.com>
Co-authored-by: Vladimir Kuvandjiev <kuvandjiev@gmail.com>
---
 html5lib/filters/sanitizer.py                | 4 ++++
 html5lib/tests/sanitizer-testdata/tests1.dat | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py
index 81c85d44..ea2c5dd3 100644
--- a/html5lib/filters/sanitizer.py
+++ b/html5lib/filters/sanitizer.py
@@ -598,6 +598,10 @@
     'height',
     'letter-spacing',
     'line-height',
+    'max-height',
+    'min-height',
+    'max-width',
+    'min-width',
     'overflow',
     'pause',
     'pause-after',
diff --git a/html5lib/tests/sanitizer-testdata/tests1.dat b/html5lib/tests/sanitizer-testdata/tests1.dat
index 74e88336..2bfbc7df 100644
--- a/html5lib/tests/sanitizer-testdata/tests1.dat
+++ b/html5lib/tests/sanitizer-testdata/tests1.dat
@@ -133,8 +133,8 @@
 
   {
     "name": "platypus",
-    "input": "<a href=\"http://www.ragingplatypus.com/\" style=\"display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;\">never trust your upstream platypus</a>",
-    "output": "<a href='http://www.ragingplatypus.com/' style='display: block; width: 100%; height: 100%; background-color: black; background-x: center; background-y: center;'>never trust your upstream platypus</a>"
+    "input": "<a href=\"http://www.ragingplatypus.com/\" style=\"display:block; position:absolute; left:0; top:0; width:100%; height:100%; min-height: 12px; max-height:1800px; min-width:12pt; max-width:3000rem; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;\">never trust your upstream platypus</a>",
+    "output": "<a href='http://www.ragingplatypus.com/' style='display: block; width: 100%; height: 100%; min-height: 12px; max-height: 1800px; min-width: 12pt; max-width: 3000rem; background-color: black; background-x: center; background-y: center;'>never trust your upstream platypus</a>"
   },
 
   {

From 4a87368b71090f1432df6302f178c4babfcec93f Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Wed, 10 Jan 2024 15:13:40 +0100
Subject: [PATCH 103/105] GitHub Actions: python: ["3.8", "3.9", "3.10",
 "3.11", "3.12"] (#575)

---
 .appveyor.yml                       | 30 +++++++++++++++++------------
 .github/workflows/python-tox.yml    | 19 ++++++++----------
 html5lib/tests/tokenizer.py         |  4 +++-
 html5lib/tests/tree_construction.py |  4 +++-
 requirements-test.txt               |  3 ++-
 5 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 7661aa63..e6f7bf48 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,23 +1,29 @@
-image: Visual Studio 2019
+# appveyor.yml - https://www.appveyor.com/docs/lang/python
+# https://www.appveyor.com/docs/windows-images-software/#visual-studio-2022
+---
+image: Visual Studio 2022
 environment:
-  global:
-    PATH: "C:\\Python27\\Scripts\\;%PATH%"
   matrix:
-    - TOXENV: py27-base
-    - TOXENV: py27-optional
-    - TOXENV: py35-base
-    - TOXENV: py35-optional
-    - TOXENV: py36-base
-    - TOXENV: py36-optional
+    - PY_PYTHON: 2.7
+      TOXENV: py27-base
+    - PY_PYTHON: 2.7
+      TOXENV: py27-optional
+    - PY_PYTHON: 3.7
+      TOXENV: py37-base
+    - PY_PYTHON: 3.7
+      TOXENV: py37-optional
 
 install:
   - git submodule update --init --recursive
-  - python -m pip install tox
+  - py --list
+  - py -VV
+  - py -m pip install --upgrade pip
+  - py -m pip install tox
 
 build: off
 
 test_script:
-  - tox
+  - py -m tox
 
 after_test:
-  - python debug-info.py
+  - py debug-info.py
diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml
index cfcc42e6..5ed83175 100644
--- a/.github/workflows/python-tox.yml
+++ b/.github/workflows/python-tox.yml
@@ -7,30 +7,27 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        # 2.7, 3.5, and 3.6 run on Windows via AppVeyor
-        python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
+        # 2.7 and 3.7 run on Windows via AppVeyor
+        python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
         os: [ubuntu-latest, windows-latest]
         deps: [base, optional]
         include:
           - python: "pypy-2.7"
             os: ubuntu-latest
             deps: base
-          - python: "pypy-3.8"
+          - python: "pypy-3.10"
             os: ubuntu-latest
             deps: base
-          - python: "2.7"
-            os: ubuntu-latest
-            deps: oldest
-          - python: "3.7"
+          - python: "3.8"
             os: ubuntu-latest
             deps: oldest
     runs-on: ${{ matrix.os }}
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
         with:
           submodules: true
       - if: ${{ matrix.deps == 'base' }}
-        uses: actions/setup-python@v4
+        uses: actions/setup-python@v5
         with:
           python-version: ${{ matrix.python }}
           cache: pip
@@ -38,7 +35,7 @@ jobs:
             requirements.txt
             requirements-test.txt
       - if: ${{ matrix.deps == 'optional' }}
-        uses: actions/setup-python@v4
+        uses: actions/setup-python@v5
         with:
           python-version: ${{ matrix.python }}
           cache: pip
@@ -47,7 +44,7 @@ jobs:
             requirements-optional.txt
             requirements-test.txt
       - if: ${{ matrix.deps == 'oldest' }}
-        uses: actions/setup-python@v4
+        uses: actions/setup-python@v5
         with:
           python-version: ${{ matrix.python }}
           cache: pip
diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py
index cc9897a4..b49d2e6e 100644
--- a/html5lib/tests/tokenizer.py
+++ b/html5lib/tests/tokenizer.py
@@ -246,7 +246,9 @@ def runtest(self):
     def repr_failure(self, excinfo):
         traceback = excinfo.traceback
         ntraceback = traceback.cut(path=__file__)
-        excinfo.traceback = ntraceback.filter()
+        pytest_ver = getattr(pytest, "version_tuple", ())
+        filter_args = (excinfo,) if pytest_ver >= (7, 4, 0) else ()
+        excinfo.traceback = ntraceback.filter(*filter_args)
 
         return excinfo.getrepr(funcargs=True,
                                showlocals=False,
diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py
index fb0657bf..363b48c2 100644
--- a/html5lib/tests/tree_construction.py
+++ b/html5lib/tests/tree_construction.py
@@ -135,7 +135,9 @@ def runtest(self):
     def repr_failure(self, excinfo):
         traceback = excinfo.traceback
         ntraceback = traceback.cut(path=__file__)
-        excinfo.traceback = ntraceback.filter()
+        pytest_ver = getattr(pytest, "version_tuple", ())
+        filter_args = (excinfo,) if pytest_ver >= (7, 4, 0) else ()
+        excinfo.traceback = ntraceback.filter(*filter_args)
 
         return excinfo.getrepr(funcargs=True,
                                showlocals=False,
diff --git a/requirements-test.txt b/requirements-test.txt
index 27866e59..39913ee4 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -3,8 +3,9 @@
 flake8==3.9.2 ; python_version < '3.6'
 flake8>=5.0.4; python_version >= '3.6'
 pytest>=4.6.10,<5 ; python_version < '3'
-pytest>=5.4.2,<7 ; python_version >= '3'
+pytest>=5.4.2,<8 ; python_version >= '3'
 coverage>=5.1,<6
 pytest-expect>=1.1.0,<2
 mock>=3.0.5,<4 ; python_version < '3.6'
 mock>=4.0.2,<5 ; python_version >= '3.6'
+setuptools; python_version >= '3.12'

From 82c2599585a6119e5afd26e58e754972c79f6734 Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz93@gmail.com>
Date: Wed, 10 Jan 2024 13:31:09 -0500
Subject: [PATCH 104/105] tests: drop dependency on external mock module for
 newer python (#574)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes #541

Co-authored-by: Å�ukasz Langa <lukasz@langa.pl>
---
 html5lib/tests/test_meta.py | 5 ++++-
 requirements-test.txt       | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/html5lib/tests/test_meta.py b/html5lib/tests/test_meta.py
index dd02dd7f..e02268aa 100644
--- a/html5lib/tests/test_meta.py
+++ b/html5lib/tests/test_meta.py
@@ -1,7 +1,10 @@
 from __future__ import absolute_import, division, unicode_literals
 
 import six
-from mock import Mock
+try:
+    from unittest.mock import Mock
+except ImportError:
+    from mock import Mock
 
 from . import support
 
diff --git a/requirements-test.txt b/requirements-test.txt
index 39913ee4..aca31f5e 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -6,6 +6,5 @@ pytest>=4.6.10,<5 ; python_version < '3'
 pytest>=5.4.2,<8 ; python_version >= '3'
 coverage>=5.1,<6
 pytest-expect>=1.1.0,<2
-mock>=3.0.5,<4 ; python_version < '3.6'
-mock>=4.0.2,<5 ; python_version >= '3.6'
+mock>=3.0.5,<4 ; python_version < '3.3'
 setuptools; python_version >= '3.12'

From fd4f032bc090d44fb11a84b352dad7cbee0a4745 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Langa?= <lukasz@langa.pl>
Date: Wed, 21 Feb 2024 16:31:38 +0100
Subject: [PATCH 105/105] Constant phases (#567)

* Get rid of getPhases

This added a fair bit of complexity, and notable made the Phase classes
dynamically generated.

However, by doing this, we no longer include "process the
token using the rules for" phases in the debug log.

Co-authored-by: Sam Sneddon <me@gsnedders.com>
---
 html5lib/_utils.py             |   12 -
 html5lib/html5parser.py        | 4349 ++++++++++++++++----------------
 html5lib/tests/test_parser2.py |    1 -
 3 files changed, 2172 insertions(+), 2190 deletions(-)

diff --git a/html5lib/_utils.py b/html5lib/_utils.py
index 9ea57942..7e23ee57 100644
--- a/html5lib/_utils.py
+++ b/html5lib/_utils.py
@@ -145,15 +145,3 @@ def moduleFactory(baseModule, *args, **kwargs):
             return mod
 
     return moduleFactory
-
-
-def memoize(func):
-    cache = {}
-
-    def wrapped(*args, **kwargs):
-        key = (tuple(args), tuple(kwargs.items()))
-        if key not in cache:
-            cache[key] = func(*args, **kwargs)
-        return cache[key]
-
-    return wrapped
diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py
index 4c2d4c75..b3c206d1 100644
--- a/html5lib/html5parser.py
+++ b/html5lib/html5parser.py
@@ -1,7 +1,5 @@
 from __future__ import absolute_import, division, unicode_literals
-from six import with_metaclass, viewkeys
-
-import types
+from six import viewkeys
 
 from . import _inputstream
 from . import _tokenizer
@@ -13,7 +11,7 @@
 from .constants import (
     spaceCharacters, asciiUpper2Lower,
     specialElements, headingElements, cdataElements, rcdataElements,
-    tokenTypes, tagTokenTypes,
+    tokenTypes,
     namespaces,
     htmlIntegrationPointElements, mathmlTextIntegrationPointElements,
     adjustForeignAttributes as adjustForeignAttributesMap,
@@ -71,18 +69,6 @@ def parseFragment(doc, container="div", treebuilder="etree", namespaceHTMLElemen
     return p.parseFragment(doc, container=container, **kwargs)
 
 
-def method_decorator_metaclass(function):
-    class Decorated(type):
-        def __new__(meta, classname, bases, classDict):
-            for attributeName, attribute in classDict.items():
-                if isinstance(attribute, types.FunctionType):
-                    attribute = function(attribute)
-
-                classDict[attributeName] = attribute
-            return type.__new__(meta, classname, bases, classDict)
-    return Decorated
-
-
 class HTMLParser(object):
     """HTML parser
 
@@ -112,6 +98,7 @@ def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=Fa
 
         # Raise an exception on the first error encountered
         self.strict = strict
+        self.debug = debug
 
         if tree is None:
             tree = treebuilders.getTreeBuilder("etree")
@@ -122,7 +109,7 @@ def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=Fa
         self.errors = []
 
         self.phases = {name: cls(self, self.tree) for name, cls in
-                       getPhases(debug).items()}
+                       _phases.items()}
 
     def _parse(self, stream, innerHTML=False, container="div", scripting=False, **kwargs):
 
@@ -204,6 +191,9 @@ def mainLoop(self):
         DoctypeToken = tokenTypes["Doctype"]
         ParseErrorToken = tokenTypes["ParseError"]
 
+        type_names = {value: key for key, value in tokenTypes.items()}
+        debug = self.debug
+
         for token in self.tokenizer:
             prev_token = None
             new_token = token
@@ -235,6 +225,17 @@ def mainLoop(self):
                     else:
                         phase = self.phases["inForeignContent"]
 
+                    if debug:
+                        info = {"type": type_names[type]}
+                        if type in (StartTagToken, EndTagToken):
+                            info["name"] = new_token['name']
+
+                        self.log.append((self.tokenizer.state.__name__,
+                                         self.phase.__class__.__name__,
+                                         phase.__class__.__name__,
+                                         "process" + info["type"],
+                                         info))
+
                     if type == CharactersToken:
                         new_token = phase.processCharacters(new_token)
                     elif type == SpaceCharactersToken:
@@ -396,2386 +397,2380 @@ def parseRCDataRawtext(self, token, contentType):
         self.phase = self.phases["text"]
 
 
-@_utils.memoize
-def getPhases(debug):
-    def log(function):
-        """Logger that records which phase processes each token"""
-        type_names = {value: key for key, value in tokenTypes.items()}
-
-        def wrapped(self, *args, **kwargs):
-            if function.__name__.startswith("process") and len(args) > 0:
-                token = args[0]
-                info = {"type": type_names[token['type']]}
-                if token['type'] in tagTokenTypes:
-                    info["name"] = token['name']
-
-                self.parser.log.append((self.parser.tokenizer.state.__name__,
-                                        self.parser.phase.__class__.__name__,
-                                        self.__class__.__name__,
-                                        function.__name__,
-                                        info))
-                return function(self, *args, **kwargs)
-            else:
-                return function(self, *args, **kwargs)
-        return wrapped
-
-    def getMetaclass(use_metaclass, metaclass_func):
-        if use_metaclass:
-            return method_decorator_metaclass(metaclass_func)
+class Phase(object):
+    """Base class for helper object that implements each phase of processing
+    """
+    __slots__ = ("parser", "tree", "__startTagCache", "__endTagCache")
+
+    def __init__(self, parser, tree):
+        self.parser = parser
+        self.tree = tree
+        self.__startTagCache = {}
+        self.__endTagCache = {}
+
+    def processEOF(self):
+        raise NotImplementedError
+
+    def processComment(self, token):
+        # For most phases the following is correct. Where it's not it will be
+        # overridden.
+        self.tree.insertComment(token, self.tree.openElements[-1])
+
+    def processDoctype(self, token):
+        self.parser.parseError("unexpected-doctype")
+
+    def processCharacters(self, token):
+        self.tree.insertText(token["data"])
+
+    def processSpaceCharacters(self, token):
+        self.tree.insertText(token["data"])
+
+    def processStartTag(self, token):
+        # Note the caching is done here rather than BoundMethodDispatcher as doing it there
+        # requires a circular reference to the Phase, and this ends up with a significant
+        # (CPython 2.7, 3.8) GC cost when parsing many short inputs
+        name = token["name"]
+        # In Py2, using `in` is quicker in general than try/except KeyError
+        # In Py3, `in` is quicker when there are few cache hits (typically short inputs)
+        if name in self.__startTagCache:
+            func = self.__startTagCache[name]
         else:
-            return type
-
-    # pylint:disable=unused-argument
-    class Phase(with_metaclass(getMetaclass(debug, log))):
-        """Base class for helper object that implements each phase of processing
-        """
-        __slots__ = ("parser", "tree", "__startTagCache", "__endTagCache")
-
-        def __init__(self, parser, tree):
-            self.parser = parser
-            self.tree = tree
-            self.__startTagCache = {}
-            self.__endTagCache = {}
-
-        def processEOF(self):
-            raise NotImplementedError
-
-        def processComment(self, token):
-            # For most phases the following is correct. Where it's not it will be
-            # overridden.
-            self.tree.insertComment(token, self.tree.openElements[-1])
-
-        def processDoctype(self, token):
-            self.parser.parseError("unexpected-doctype")
-
-        def processCharacters(self, token):
-            self.tree.insertText(token["data"])
-
-        def processSpaceCharacters(self, token):
-            self.tree.insertText(token["data"])
-
-        def processStartTag(self, token):
-            # Note the caching is done here rather than BoundMethodDispatcher as doing it there
-            # requires a circular reference to the Phase, and this ends up with a significant
-            # (CPython 2.7, 3.8) GC cost when parsing many short inputs
-            name = token["name"]
-            # In Py2, using `in` is quicker in general than try/except KeyError
-            # In Py3, `in` is quicker when there are few cache hits (typically short inputs)
-            if name in self.__startTagCache:
-                func = self.__startTagCache[name]
-            else:
-                func = self.__startTagCache[name] = self.startTagHandler[name]
-                # bound the cache size in case we get loads of unknown tags
-                while len(self.__startTagCache) > len(self.startTagHandler) * 1.1:
-                    # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
-                    self.__startTagCache.pop(next(iter(self.__startTagCache)))
-            return func(token)
-
-        def startTagHtml(self, token):
-            if not self.parser.firstStartTag and token["name"] == "html":
-                self.parser.parseError("non-html-root")
-            # XXX Need a check here to see if the first start tag token emitted is
-            # this token... If it's not, invoke self.parser.parseError().
-            for attr, value in token["data"].items():
-                if attr not in self.tree.openElements[0].attributes:
-                    self.tree.openElements[0].attributes[attr] = value
-            self.parser.firstStartTag = False
-
-        def processEndTag(self, token):
-            # Note the caching is done here rather than BoundMethodDispatcher as doing it there
-            # requires a circular reference to the Phase, and this ends up with a significant
-            # (CPython 2.7, 3.8) GC cost when parsing many short inputs
-            name = token["name"]
-            # In Py2, using `in` is quicker in general than try/except KeyError
-            # In Py3, `in` is quicker when there are few cache hits (typically short inputs)
-            if name in self.__endTagCache:
-                func = self.__endTagCache[name]
-            else:
-                func = self.__endTagCache[name] = self.endTagHandler[name]
-                # bound the cache size in case we get loads of unknown tags
-                while len(self.__endTagCache) > len(self.endTagHandler) * 1.1:
-                    # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
-                    self.__endTagCache.pop(next(iter(self.__endTagCache)))
-            return func(token)
-
-    class InitialPhase(Phase):
-        __slots__ = tuple()
-
-        def processSpaceCharacters(self, token):
-            pass
-
-        def processComment(self, token):
-            self.tree.insertComment(token, self.tree.document)
-
-        def processDoctype(self, token):
-            name = token["name"]
-            publicId = token["publicId"]
-            systemId = token["systemId"]
-            correct = token["correct"]
-
-            if (name != "html" or publicId is not None or
-                    systemId is not None and systemId != "about:legacy-compat"):
-                self.parser.parseError("unknown-doctype")
-
-            if publicId is None:
-                publicId = ""
-
-            self.tree.insertDoctype(token)
-
-            if publicId != "":
-                publicId = publicId.translate(asciiUpper2Lower)
-
-            if (not correct or token["name"] != "html" or
-                    publicId.startswith(
-                        ("+//silmaril//dtd html pro v0r11 19970101//",
-                         "-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
-                         "-//as//dtd html 3.0 aswedit + extensions//",
-                         "-//ietf//dtd html 2.0 level 1//",
-                         "-//ietf//dtd html 2.0 level 2//",
-                         "-//ietf//dtd html 2.0 strict level 1//",
-                         "-//ietf//dtd html 2.0 strict level 2//",
-                         "-//ietf//dtd html 2.0 strict//",
-                         "-//ietf//dtd html 2.0//",
-                         "-//ietf//dtd html 2.1e//",
-                         "-//ietf//dtd html 3.0//",
-                         "-//ietf//dtd html 3.2 final//",
-                         "-//ietf//dtd html 3.2//",
-                         "-//ietf//dtd html 3//",
-                         "-//ietf//dtd html level 0//",
-                         "-//ietf//dtd html level 1//",
-                         "-//ietf//dtd html level 2//",
-                         "-//ietf//dtd html level 3//",
-                         "-//ietf//dtd html strict level 0//",
-                         "-//ietf//dtd html strict level 1//",
-                         "-//ietf//dtd html strict level 2//",
-                         "-//ietf//dtd html strict level 3//",
-                         "-//ietf//dtd html strict//",
-                         "-//ietf//dtd html//",
-                         "-//metrius//dtd metrius presentational//",
-                         "-//microsoft//dtd internet explorer 2.0 html strict//",
-                         "-//microsoft//dtd internet explorer 2.0 html//",
-                         "-//microsoft//dtd internet explorer 2.0 tables//",
-                         "-//microsoft//dtd internet explorer 3.0 html strict//",
-                         "-//microsoft//dtd internet explorer 3.0 html//",
-                         "-//microsoft//dtd internet explorer 3.0 tables//",
-                         "-//netscape comm. corp.//dtd html//",
-                         "-//netscape comm. corp.//dtd strict html//",
-                         "-//o'reilly and associates//dtd html 2.0//",
-                         "-//o'reilly and associates//dtd html extended 1.0//",
-                         "-//o'reilly and associates//dtd html extended relaxed 1.0//",
-                         "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//",
-                         "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//",
-                         "-//spyglass//dtd html 2.0 extended//",
-                         "-//sq//dtd html 2.0 hotmetal + extensions//",
-                         "-//sun microsystems corp.//dtd hotjava html//",
-                         "-//sun microsystems corp.//dtd hotjava strict html//",
-                         "-//w3c//dtd html 3 1995-03-24//",
-                         "-//w3c//dtd html 3.2 draft//",
-                         "-//w3c//dtd html 3.2 final//",
-                         "-//w3c//dtd html 3.2//",
-                         "-//w3c//dtd html 3.2s draft//",
-                         "-//w3c//dtd html 4.0 frameset//",
-                         "-//w3c//dtd html 4.0 transitional//",
-                         "-//w3c//dtd html experimental 19960712//",
-                         "-//w3c//dtd html experimental 970421//",
-                         "-//w3c//dtd w3 html//",
-                         "-//w3o//dtd w3 html 3.0//",
-                         "-//webtechs//dtd mozilla html 2.0//",
-                         "-//webtechs//dtd mozilla html//")) or
-                    publicId in ("-//w3o//dtd w3 html strict 3.0//en//",
-                                 "-/w3c/dtd html 4.0 transitional/en",
-                                 "html") or
-                    publicId.startswith(
-                        ("-//w3c//dtd html 4.01 frameset//",
-                         "-//w3c//dtd html 4.01 transitional//")) and
-                    systemId is None or
-                    systemId and systemId.lower() == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"):
-                self.parser.compatMode = "quirks"
-            elif (publicId.startswith(
-                    ("-//w3c//dtd xhtml 1.0 frameset//",
-                     "-//w3c//dtd xhtml 1.0 transitional//")) or
-                  publicId.startswith(
-                      ("-//w3c//dtd html 4.01 frameset//",
-                       "-//w3c//dtd html 4.01 transitional//")) and
-                  systemId is not None):
-                self.parser.compatMode = "limited quirks"
-
-            self.parser.phase = self.parser.phases["beforeHtml"]
-
-        def anythingElse(self):
+            func = self.__startTagCache[name] = self.startTagHandler[name]
+            # bound the cache size in case we get loads of unknown tags
+            while len(self.__startTagCache) > len(self.startTagHandler) * 1.1:
+                # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
+                self.__startTagCache.pop(next(iter(self.__startTagCache)))
+        return func(token)
+
+    def startTagHtml(self, token):
+        if not self.parser.firstStartTag and token["name"] == "html":
+            self.parser.parseError("non-html-root")
+        # XXX Need a check here to see if the first start tag token emitted is
+        # this token... If it's not, invoke self.parser.parseError().
+        for attr, value in token["data"].items():
+            if attr not in self.tree.openElements[0].attributes:
+                self.tree.openElements[0].attributes[attr] = value
+        self.parser.firstStartTag = False
+
+    def processEndTag(self, token):
+        # Note the caching is done here rather than BoundMethodDispatcher as doing it there
+        # requires a circular reference to the Phase, and this ends up with a significant
+        # (CPython 2.7, 3.8) GC cost when parsing many short inputs
+        name = token["name"]
+        # In Py2, using `in` is quicker in general than try/except KeyError
+        # In Py3, `in` is quicker when there are few cache hits (typically short inputs)
+        if name in self.__endTagCache:
+            func = self.__endTagCache[name]
+        else:
+            func = self.__endTagCache[name] = self.endTagHandler[name]
+            # bound the cache size in case we get loads of unknown tags
+            while len(self.__endTagCache) > len(self.endTagHandler) * 1.1:
+                # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
+                self.__endTagCache.pop(next(iter(self.__endTagCache)))
+        return func(token)
+
+
+class InitialPhase(Phase):
+    __slots__ = tuple()
+
+    def processSpaceCharacters(self, token):
+        pass
+
+    def processComment(self, token):
+        self.tree.insertComment(token, self.tree.document)
+
+    def processDoctype(self, token):
+        name = token["name"]
+        publicId = token["publicId"]
+        systemId = token["systemId"]
+        correct = token["correct"]
+
+        if (name != "html" or publicId is not None or
+                systemId is not None and systemId != "about:legacy-compat"):
+            self.parser.parseError("unknown-doctype")
+
+        if publicId is None:
+            publicId = ""
+
+        self.tree.insertDoctype(token)
+
+        if publicId != "":
+            publicId = publicId.translate(asciiUpper2Lower)
+
+        if (not correct or token["name"] != "html" or
+                publicId.startswith(
+                    ("+//silmaril//dtd html pro v0r11 19970101//",
+                     "-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
+                     "-//as//dtd html 3.0 aswedit + extensions//",
+                     "-//ietf//dtd html 2.0 level 1//",
+                     "-//ietf//dtd html 2.0 level 2//",
+                     "-//ietf//dtd html 2.0 strict level 1//",
+                     "-//ietf//dtd html 2.0 strict level 2//",
+                     "-//ietf//dtd html 2.0 strict//",
+                     "-//ietf//dtd html 2.0//",
+                     "-//ietf//dtd html 2.1e//",
+                     "-//ietf//dtd html 3.0//",
+                     "-//ietf//dtd html 3.2 final//",
+                     "-//ietf//dtd html 3.2//",
+                     "-//ietf//dtd html 3//",
+                     "-//ietf//dtd html level 0//",
+                     "-//ietf//dtd html level 1//",
+                     "-//ietf//dtd html level 2//",
+                     "-//ietf//dtd html level 3//",
+                     "-//ietf//dtd html strict level 0//",
+                     "-//ietf//dtd html strict level 1//",
+                     "-//ietf//dtd html strict level 2//",
+                     "-//ietf//dtd html strict level 3//",
+                     "-//ietf//dtd html strict//",
+                     "-//ietf//dtd html//",
+                     "-//metrius//dtd metrius presentational//",
+                     "-//microsoft//dtd internet explorer 2.0 html strict//",
+                     "-//microsoft//dtd internet explorer 2.0 html//",
+                     "-//microsoft//dtd internet explorer 2.0 tables//",
+                     "-//microsoft//dtd internet explorer 3.0 html strict//",
+                     "-//microsoft//dtd internet explorer 3.0 html//",
+                     "-//microsoft//dtd internet explorer 3.0 tables//",
+                     "-//netscape comm. corp.//dtd html//",
+                     "-//netscape comm. corp.//dtd strict html//",
+                     "-//o'reilly and associates//dtd html 2.0//",
+                     "-//o'reilly and associates//dtd html extended 1.0//",
+                     "-//o'reilly and associates//dtd html extended relaxed 1.0//",
+                     "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//",
+                     "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//",
+                     "-//spyglass//dtd html 2.0 extended//",
+                     "-//sq//dtd html 2.0 hotmetal + extensions//",
+                     "-//sun microsystems corp.//dtd hotjava html//",
+                     "-//sun microsystems corp.//dtd hotjava strict html//",
+                     "-//w3c//dtd html 3 1995-03-24//",
+                     "-//w3c//dtd html 3.2 draft//",
+                     "-//w3c//dtd html 3.2 final//",
+                     "-//w3c//dtd html 3.2//",
+                     "-//w3c//dtd html 3.2s draft//",
+                     "-//w3c//dtd html 4.0 frameset//",
+                     "-//w3c//dtd html 4.0 transitional//",
+                     "-//w3c//dtd html experimental 19960712//",
+                     "-//w3c//dtd html experimental 970421//",
+                     "-//w3c//dtd w3 html//",
+                     "-//w3o//dtd w3 html 3.0//",
+                     "-//webtechs//dtd mozilla html 2.0//",
+                     "-//webtechs//dtd mozilla html//")) or
+                publicId in ("-//w3o//dtd w3 html strict 3.0//en//",
+                             "-/w3c/dtd html 4.0 transitional/en",
+                             "html") or
+                publicId.startswith(
+                    ("-//w3c//dtd html 4.01 frameset//",
+                     "-//w3c//dtd html 4.01 transitional//")) and
+                systemId is None or
+                systemId and systemId.lower() == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"):
             self.parser.compatMode = "quirks"
-            self.parser.phase = self.parser.phases["beforeHtml"]
-
-        def processCharacters(self, token):
-            self.parser.parseError("expected-doctype-but-got-chars")
-            self.anythingElse()
-            return token
-
-        def processStartTag(self, token):
-            self.parser.parseError("expected-doctype-but-got-start-tag",
+        elif (publicId.startswith(
+                ("-//w3c//dtd xhtml 1.0 frameset//",
+                 "-//w3c//dtd xhtml 1.0 transitional//")) or
+              publicId.startswith(
+                  ("-//w3c//dtd html 4.01 frameset//",
+                   "-//w3c//dtd html 4.01 transitional//")) and
+              systemId is not None):
+            self.parser.compatMode = "limited quirks"
+
+        self.parser.phase = self.parser.phases["beforeHtml"]
+
+    def anythingElse(self):
+        self.parser.compatMode = "quirks"
+        self.parser.phase = self.parser.phases["beforeHtml"]
+
+    def processCharacters(self, token):
+        self.parser.parseError("expected-doctype-but-got-chars")
+        self.anythingElse()
+        return token
+
+    def processStartTag(self, token):
+        self.parser.parseError("expected-doctype-but-got-start-tag",
+                               {"name": token["name"]})
+        self.anythingElse()
+        return token
+
+    def processEndTag(self, token):
+        self.parser.parseError("expected-doctype-but-got-end-tag",
+                               {"name": token["name"]})
+        self.anythingElse()
+        return token
+
+    def processEOF(self):
+        self.parser.parseError("expected-doctype-but-got-eof")
+        self.anythingElse()
+        return True
+
+
+class BeforeHtmlPhase(Phase):
+    __slots__ = tuple()
+
+    # helper methods
+    def insertHtmlElement(self):
+        self.tree.insertRoot(impliedTagToken("html", "StartTag"))
+        self.parser.phase = self.parser.phases["beforeHead"]
+
+    # other
+    def processEOF(self):
+        self.insertHtmlElement()
+        return True
+
+    def processComment(self, token):
+        self.tree.insertComment(token, self.tree.document)
+
+    def processSpaceCharacters(self, token):
+        pass
+
+    def processCharacters(self, token):
+        self.insertHtmlElement()
+        return token
+
+    def processStartTag(self, token):
+        if token["name"] == "html":
+            self.parser.firstStartTag = True
+        self.insertHtmlElement()
+        return token
+
+    def processEndTag(self, token):
+        if token["name"] not in ("head", "body", "html", "br"):
+            self.parser.parseError("unexpected-end-tag-before-html",
                                    {"name": token["name"]})
-            self.anythingElse()
+        else:
+            self.insertHtmlElement()
             return token
 
-        def processEndTag(self, token):
-            self.parser.parseError("expected-doctype-but-got-end-tag",
-                                   {"name": token["name"]})
-            self.anythingElse()
-            return token
 
-        def processEOF(self):
-            self.parser.parseError("expected-doctype-but-got-eof")
-            self.anythingElse()
-            return True
+class BeforeHeadPhase(Phase):
+    __slots__ = tuple()
 
-    class BeforeHtmlPhase(Phase):
-        __slots__ = tuple()
+    def processEOF(self):
+        self.startTagHead(impliedTagToken("head", "StartTag"))
+        return True
 
-        # helper methods
-        def insertHtmlElement(self):
-            self.tree.insertRoot(impliedTagToken("html", "StartTag"))
-            self.parser.phase = self.parser.phases["beforeHead"]
+    def processSpaceCharacters(self, token):
+        pass
 
-        # other
-        def processEOF(self):
-            self.insertHtmlElement()
-            return True
+    def processCharacters(self, token):
+        self.startTagHead(impliedTagToken("head", "StartTag"))
+        return token
 
-        def processComment(self, token):
-            self.tree.insertComment(token, self.tree.document)
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
 
-        def processSpaceCharacters(self, token):
-            pass
+    def startTagHead(self, token):
+        self.tree.insertElement(token)
+        self.tree.headPointer = self.tree.openElements[-1]
+        self.parser.phase = self.parser.phases["inHead"]
 
-        def processCharacters(self, token):
-            self.insertHtmlElement()
-            return token
+    def startTagOther(self, token):
+        self.startTagHead(impliedTagToken("head", "StartTag"))
+        return token
 
-        def processStartTag(self, token):
-            if token["name"] == "html":
-                self.parser.firstStartTag = True
-            self.insertHtmlElement()
-            return token
+    def endTagImplyHead(self, token):
+        self.startTagHead(impliedTagToken("head", "StartTag"))
+        return token
 
-        def processEndTag(self, token):
-            if token["name"] not in ("head", "body", "html", "br"):
-                self.parser.parseError("unexpected-end-tag-before-html",
-                                       {"name": token["name"]})
-            else:
-                self.insertHtmlElement()
-                return token
+    def endTagOther(self, token):
+        self.parser.parseError("end-tag-after-implied-root",
+                               {"name": token["name"]})
 
-    class BeforeHeadPhase(Phase):
-        __slots__ = tuple()
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml),
+        ("head", startTagHead)
+    ])
+    startTagHandler.default = startTagOther
 
-        def processEOF(self):
-            self.startTagHead(impliedTagToken("head", "StartTag"))
-            return True
+    endTagHandler = _utils.MethodDispatcher([
+        (("head", "body", "html", "br"), endTagImplyHead)
+    ])
+    endTagHandler.default = endTagOther
 
-        def processSpaceCharacters(self, token):
-            pass
 
-        def processCharacters(self, token):
-            self.startTagHead(impliedTagToken("head", "StartTag"))
-            return token
+class InHeadPhase(Phase):
+    __slots__ = tuple()
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    # the real thing
+    def processEOF(self):
+        self.anythingElse()
+        return True
 
-        def startTagHead(self, token):
-            self.tree.insertElement(token)
-            self.tree.headPointer = self.tree.openElements[-1]
-            self.parser.phase = self.parser.phases["inHead"]
+    def processCharacters(self, token):
+        self.anythingElse()
+        return token
 
-        def startTagOther(self, token):
-            self.startTagHead(impliedTagToken("head", "StartTag"))
-            return token
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
 
-        def endTagImplyHead(self, token):
-            self.startTagHead(impliedTagToken("head", "StartTag"))
-            return token
+    def startTagHead(self, token):
+        self.parser.parseError("two-heads-are-not-better-than-one")
 
-        def endTagOther(self, token):
-            self.parser.parseError("end-tag-after-implied-root",
-                                   {"name": token["name"]})
+    def startTagBaseLinkCommand(self, token):
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
+        token["selfClosingAcknowledged"] = True
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml),
-            ("head", startTagHead)
-        ])
-        startTagHandler.default = startTagOther
+    def startTagMeta(self, token):
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
+        token["selfClosingAcknowledged"] = True
+
+        attributes = token["data"]
+        if self.parser.tokenizer.stream.charEncoding[1] == "tentative":
+            if "charset" in attributes:
+                self.parser.tokenizer.stream.changeEncoding(attributes["charset"])
+            elif ("content" in attributes and
+                  "http-equiv" in attributes and
+                  attributes["http-equiv"].lower() == "content-type"):
+                # Encoding it as UTF-8 here is a hack, as really we should pass
+                # 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)
+                codec = parser.parse()
+                self.parser.tokenizer.stream.changeEncoding(codec)
+
+    def startTagTitle(self, token):
+        self.parser.parseRCDataRawtext(token, "RCDATA")
+
+    def startTagNoFramesStyle(self, token):
+        # Need to decide whether to implement the scripting-disabled case
+        self.parser.parseRCDataRawtext(token, "RAWTEXT")
+
+    def startTagNoscript(self, token):
+        if self.parser.scripting:
+            self.parser.parseRCDataRawtext(token, "RAWTEXT")
+        else:
+            self.tree.insertElement(token)
+            self.parser.phase = self.parser.phases["inHeadNoscript"]
 
-        endTagHandler = _utils.MethodDispatcher([
-            (("head", "body", "html", "br"), endTagImplyHead)
-        ])
-        endTagHandler.default = endTagOther
+    def startTagScript(self, token):
+        self.tree.insertElement(token)
+        self.parser.tokenizer.state = self.parser.tokenizer.scriptDataState
+        self.parser.originalPhase = self.parser.phase
+        self.parser.phase = self.parser.phases["text"]
+
+    def startTagOther(self, token):
+        self.anythingElse()
+        return token
+
+    def endTagHead(self, token):
+        node = self.parser.tree.openElements.pop()
+        assert node.name == "head", "Expected head got %s" % node.name
+        self.parser.phase = self.parser.phases["afterHead"]
+
+    def endTagHtmlBodyBr(self, token):
+        self.anythingElse()
+        return token
+
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+
+    def anythingElse(self):
+        self.endTagHead(impliedTagToken("head"))
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml),
+        ("title", startTagTitle),
+        (("noframes", "style"), startTagNoFramesStyle),
+        ("noscript", startTagNoscript),
+        ("script", startTagScript),
+        (("base", "basefont", "bgsound", "command", "link"),
+         startTagBaseLinkCommand),
+        ("meta", startTagMeta),
+        ("head", startTagHead)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("head", endTagHead),
+        (("br", "html", "body"), endTagHtmlBodyBr)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class InHeadNoscriptPhase(Phase):
+    __slots__ = tuple()
+
+    def processEOF(self):
+        self.parser.parseError("eof-in-head-noscript")
+        self.anythingElse()
+        return True
+
+    def processComment(self, token):
+        return self.parser.phases["inHead"].processComment(token)
+
+    def processCharacters(self, token):
+        self.parser.parseError("char-in-head-noscript")
+        self.anythingElse()
+        return token
+
+    def processSpaceCharacters(self, token):
+        return self.parser.phases["inHead"].processSpaceCharacters(token)
+
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
+
+    def startTagBaseLinkCommand(self, token):
+        return self.parser.phases["inHead"].processStartTag(token)
+
+    def startTagHeadNoscript(self, token):
+        self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
+
+    def startTagOther(self, token):
+        self.parser.parseError("unexpected-inhead-noscript-tag", {"name": token["name"]})
+        self.anythingElse()
+        return token
+
+    def endTagNoscript(self, token):
+        node = self.parser.tree.openElements.pop()
+        assert node.name == "noscript", "Expected noscript got %s" % node.name
+        self.parser.phase = self.parser.phases["inHead"]
+
+    def endTagBr(self, token):
+        self.parser.parseError("unexpected-inhead-noscript-tag", {"name": token["name"]})
+        self.anythingElse()
+        return token
+
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+
+    def anythingElse(self):
+        # Caller must raise parse error first!
+        self.endTagNoscript(impliedTagToken("noscript"))
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml),
+        (("basefont", "bgsound", "link", "meta", "noframes", "style"), startTagBaseLinkCommand),
+        (("head", "noscript"), startTagHeadNoscript),
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("noscript", endTagNoscript),
+        ("br", endTagBr),
+    ])
+    endTagHandler.default = endTagOther
+
+
+class AfterHeadPhase(Phase):
+    __slots__ = tuple()
+
+    def processEOF(self):
+        self.anythingElse()
+        return True
+
+    def processCharacters(self, token):
+        self.anythingElse()
+        return token
+
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
+
+    def startTagBody(self, token):
+        self.parser.framesetOK = False
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inBody"]
 
-    class InHeadPhase(Phase):
-        __slots__ = tuple()
+    def startTagFrameset(self, token):
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inFrameset"]
 
-        # the real thing
-        def processEOF(self):
-            self.anythingElse()
-            return True
+    def startTagFromHead(self, token):
+        self.parser.parseError("unexpected-start-tag-out-of-my-head",
+                               {"name": token["name"]})
+        self.tree.openElements.append(self.tree.headPointer)
+        self.parser.phases["inHead"].processStartTag(token)
+        for node in self.tree.openElements[::-1]:
+            if node.name == "head":
+                self.tree.openElements.remove(node)
+                break
 
-        def processCharacters(self, token):
-            self.anythingElse()
-            return token
+    def startTagHead(self, token):
+        self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
+
+    def startTagOther(self, token):
+        self.anythingElse()
+        return token
+
+    def endTagHtmlBodyBr(self, token):
+        self.anythingElse()
+        return token
+
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+
+    def anythingElse(self):
+        self.tree.insertElement(impliedTagToken("body", "StartTag"))
+        self.parser.phase = self.parser.phases["inBody"]
+        self.parser.framesetOK = True
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml),
+        ("body", startTagBody),
+        ("frameset", startTagFrameset),
+        (("base", "basefont", "bgsound", "link", "meta", "noframes", "script",
+          "style", "title"),
+         startTagFromHead),
+        ("head", startTagHead)
+    ])
+    startTagHandler.default = startTagOther
+    endTagHandler = _utils.MethodDispatcher([(("body", "html", "br"),
+                                              endTagHtmlBodyBr)])
+    endTagHandler.default = endTagOther
+
+
+class InBodyPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#parsing-main-inbody
+    # the really-really-really-very crazy mode
+    __slots__ = ("processSpaceCharacters",)
+
+    def __init__(self, *args, **kwargs):
+        super(InBodyPhase, self).__init__(*args, **kwargs)
+        # Set this to the default handler
+        self.processSpaceCharacters = self.processSpaceCharactersNonPre
+
+    def isMatchingFormattingElement(self, node1, node2):
+        return (node1.name == node2.name and
+                node1.namespace == node2.namespace and
+                node1.attributes == node2.attributes)
+
+    # helper
+    def addFormattingElement(self, token):
+        self.tree.insertElement(token)
+        element = self.tree.openElements[-1]
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+        matchingElements = []
+        for node in self.tree.activeFormattingElements[::-1]:
+            if node is Marker:
+                break
+            elif self.isMatchingFormattingElement(node, element):
+                matchingElements.append(node)
+
+        assert len(matchingElements) <= 3
+        if len(matchingElements) == 3:
+            self.tree.activeFormattingElements.remove(matchingElements[-1])
+        self.tree.activeFormattingElements.append(element)
+
+    # the real deal
+    def processEOF(self):
+        allowed_elements = frozenset(("dd", "dt", "li", "p", "tbody", "td",
+                                      "tfoot", "th", "thead", "tr", "body",
+                                      "html"))
+        for node in self.tree.openElements[::-1]:
+            if node.name not in allowed_elements:
+                self.parser.parseError("expected-closing-tag-but-got-eof")
+                break
+        # Stop parsing
+
+    def processSpaceCharactersDropNewline(self, token):
+        # Sometimes (start of <pre>, <listing>, and <textarea> blocks) we
+        # want to drop leading newlines
+        data = token["data"]
+        self.processSpaceCharacters = self.processSpaceCharactersNonPre
+        if (data.startswith("\n") and
+            self.tree.openElements[-1].name in ("pre", "listing", "textarea") and
+                not self.tree.openElements[-1].hasContent()):
+            data = data[1:]
+        if data:
+            self.tree.reconstructActiveFormattingElements()
+            self.tree.insertText(data)
+
+    def processCharacters(self, token):
+        if token["data"] == "\u0000":
+            # The tokenizer should always emit null on its own
+            return
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertText(token["data"])
+        # This must be bad for performance
+        if (self.parser.framesetOK and
+            any(char not in spaceCharacters
+                for char in token["data"])):
+            self.parser.framesetOK = False
 
-        def startTagHead(self, token):
-            self.parser.parseError("two-heads-are-not-better-than-one")
+    def processSpaceCharactersNonPre(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertText(token["data"])
 
-        def startTagBaseLinkCommand(self, token):
-            self.tree.insertElement(token)
-            self.tree.openElements.pop()
-            token["selfClosingAcknowledged"] = True
+    def startTagProcessInHead(self, token):
+        return self.parser.phases["inHead"].processStartTag(token)
 
-        def startTagMeta(self, token):
+    def startTagBody(self, token):
+        self.parser.parseError("unexpected-start-tag", {"name": "body"})
+        if (len(self.tree.openElements) == 1 or
+                self.tree.openElements[1].name != "body"):
+            assert self.parser.innerHTML
+        else:
+            self.parser.framesetOK = False
+            for attr, value in token["data"].items():
+                if attr not in self.tree.openElements[1].attributes:
+                    self.tree.openElements[1].attributes[attr] = value
+
+    def startTagFrameset(self, token):
+        self.parser.parseError("unexpected-start-tag", {"name": "frameset"})
+        if (len(self.tree.openElements) == 1 or self.tree.openElements[1].name != "body"):
+            assert self.parser.innerHTML
+        elif not self.parser.framesetOK:
+            pass
+        else:
+            if self.tree.openElements[1].parent:
+                self.tree.openElements[1].parent.removeChild(self.tree.openElements[1])
+            while self.tree.openElements[-1].name != "html":
+                self.tree.openElements.pop()
             self.tree.insertElement(token)
-            self.tree.openElements.pop()
-            token["selfClosingAcknowledged"] = True
+            self.parser.phase = self.parser.phases["inFrameset"]
 
-            attributes = token["data"]
-            if self.parser.tokenizer.stream.charEncoding[1] == "tentative":
-                if "charset" in attributes:
-                    self.parser.tokenizer.stream.changeEncoding(attributes["charset"])
-                elif ("content" in attributes and
-                      "http-equiv" in attributes and
-                      attributes["http-equiv"].lower() == "content-type"):
-                    # Encoding it as UTF-8 here is a hack, as really we should pass
-                    # 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)
-                    codec = parser.parse()
-                    self.parser.tokenizer.stream.changeEncoding(codec)
-
-        def startTagTitle(self, token):
-            self.parser.parseRCDataRawtext(token, "RCDATA")
-
-        def startTagNoFramesStyle(self, token):
-            # Need to decide whether to implement the scripting-disabled case
-            self.parser.parseRCDataRawtext(token, "RAWTEXT")
+    def startTagCloseP(self, token):
+        if self.tree.elementInScope("p", variant="button"):
+            self.endTagP(impliedTagToken("p"))
+        self.tree.insertElement(token)
 
-        def startTagNoscript(self, token):
-            if self.parser.scripting:
-                self.parser.parseRCDataRawtext(token, "RAWTEXT")
-            else:
-                self.tree.insertElement(token)
-                self.parser.phase = self.parser.phases["inHeadNoscript"]
+    def startTagPreListing(self, token):
+        if self.tree.elementInScope("p", variant="button"):
+            self.endTagP(impliedTagToken("p"))
+        self.tree.insertElement(token)
+        self.parser.framesetOK = False
+        self.processSpaceCharacters = self.processSpaceCharactersDropNewline
 
-        def startTagScript(self, token):
+    def startTagForm(self, token):
+        if self.tree.formPointer:
+            self.parser.parseError("unexpected-start-tag", {"name": "form"})
+        else:
+            if self.tree.elementInScope("p", variant="button"):
+                self.endTagP(impliedTagToken("p"))
             self.tree.insertElement(token)
-            self.parser.tokenizer.state = self.parser.tokenizer.scriptDataState
-            self.parser.originalPhase = self.parser.phase
-            self.parser.phase = self.parser.phases["text"]
+            self.tree.formPointer = self.tree.openElements[-1]
 
-        def startTagOther(self, token):
-            self.anythingElse()
-            return token
+    def startTagListItem(self, token):
+        self.parser.framesetOK = False
 
-        def endTagHead(self, token):
-            node = self.parser.tree.openElements.pop()
-            assert node.name == "head", "Expected head got %s" % node.name
-            self.parser.phase = self.parser.phases["afterHead"]
+        stopNamesMap = {"li": ["li"],
+                        "dt": ["dt", "dd"],
+                        "dd": ["dt", "dd"]}
+        stopNames = stopNamesMap[token["name"]]
+        for node in reversed(self.tree.openElements):
+            if node.name in stopNames:
+                self.parser.phase.processEndTag(
+                    impliedTagToken(node.name, "EndTag"))
+                break
+            if (node.nameTuple in specialElements and
+                    node.name not in ("address", "div", "p")):
+                break
 
-        def endTagHtmlBodyBr(self, token):
-            self.anythingElse()
-            return token
+        if self.tree.elementInScope("p", variant="button"):
+            self.parser.phase.processEndTag(
+                impliedTagToken("p", "EndTag"))
 
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+        self.tree.insertElement(token)
 
-        def anythingElse(self):
-            self.endTagHead(impliedTagToken("head"))
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml),
-            ("title", startTagTitle),
-            (("noframes", "style"), startTagNoFramesStyle),
-            ("noscript", startTagNoscript),
-            ("script", startTagScript),
-            (("base", "basefont", "bgsound", "command", "link"),
-             startTagBaseLinkCommand),
-            ("meta", startTagMeta),
-            ("head", startTagHead)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("head", endTagHead),
-            (("br", "html", "body"), endTagHtmlBodyBr)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InHeadNoscriptPhase(Phase):
-        __slots__ = tuple()
-
-        def processEOF(self):
-            self.parser.parseError("eof-in-head-noscript")
-            self.anythingElse()
-            return True
-
-        def processComment(self, token):
-            return self.parser.phases["inHead"].processComment(token)
-
-        def processCharacters(self, token):
-            self.parser.parseError("char-in-head-noscript")
-            self.anythingElse()
-            return token
+    def startTagPlaintext(self, token):
+        if self.tree.elementInScope("p", variant="button"):
+            self.endTagP(impliedTagToken("p"))
+        self.tree.insertElement(token)
+        self.parser.tokenizer.state = self.parser.tokenizer.plaintextState
 
-        def processSpaceCharacters(self, token):
-            return self.parser.phases["inHead"].processSpaceCharacters(token)
+    def startTagHeading(self, token):
+        if self.tree.elementInScope("p", variant="button"):
+            self.endTagP(impliedTagToken("p"))
+        if self.tree.openElements[-1].name in headingElements:
+            self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
+            self.tree.openElements.pop()
+        self.tree.insertElement(token)
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def startTagA(self, token):
+        afeAElement = self.tree.elementInActiveFormattingElements("a")
+        if afeAElement:
+            self.parser.parseError("unexpected-start-tag-implies-end-tag",
+                                   {"startName": "a", "endName": "a"})
+            self.endTagFormatting(impliedTagToken("a"))
+            if afeAElement in self.tree.openElements:
+                self.tree.openElements.remove(afeAElement)
+            if afeAElement in self.tree.activeFormattingElements:
+                self.tree.activeFormattingElements.remove(afeAElement)
+        self.tree.reconstructActiveFormattingElements()
+        self.addFormattingElement(token)
+
+    def startTagFormatting(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.addFormattingElement(token)
+
+    def startTagNobr(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        if self.tree.elementInScope("nobr"):
+            self.parser.parseError("unexpected-start-tag-implies-end-tag",
+                                   {"startName": "nobr", "endName": "nobr"})
+            self.processEndTag(impliedTagToken("nobr"))
+            # XXX Need tests that trigger the following
+            self.tree.reconstructActiveFormattingElements()
+        self.addFormattingElement(token)
 
-        def startTagBaseLinkCommand(self, token):
-            return self.parser.phases["inHead"].processStartTag(token)
+    def startTagButton(self, token):
+        if self.tree.elementInScope("button"):
+            self.parser.parseError("unexpected-start-tag-implies-end-tag",
+                                   {"startName": "button", "endName": "button"})
+            self.processEndTag(impliedTagToken("button"))
+            return token
+        else:
+            self.tree.reconstructActiveFormattingElements()
+            self.tree.insertElement(token)
+            self.parser.framesetOK = False
 
-        def startTagHeadNoscript(self, token):
-            self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
+    def startTagAppletMarqueeObject(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertElement(token)
+        self.tree.activeFormattingElements.append(Marker)
+        self.parser.framesetOK = False
+
+    def startTagXmp(self, token):
+        if self.tree.elementInScope("p", variant="button"):
+            self.endTagP(impliedTagToken("p"))
+        self.tree.reconstructActiveFormattingElements()
+        self.parser.framesetOK = False
+        self.parser.parseRCDataRawtext(token, "RAWTEXT")
+
+    def startTagTable(self, token):
+        if self.parser.compatMode != "quirks":
+            if self.tree.elementInScope("p", variant="button"):
+                self.processEndTag(impliedTagToken("p"))
+        self.tree.insertElement(token)
+        self.parser.framesetOK = False
+        self.parser.phase = self.parser.phases["inTable"]
 
-        def startTagOther(self, token):
-            self.parser.parseError("unexpected-inhead-noscript-tag", {"name": token["name"]})
-            self.anythingElse()
-            return token
+    def startTagVoidFormatting(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
+        token["selfClosingAcknowledged"] = True
+        self.parser.framesetOK = False
+
+    def startTagInput(self, token):
+        framesetOK = self.parser.framesetOK
+        self.startTagVoidFormatting(token)
+        if ("type" in token["data"] and
+                token["data"]["type"].translate(asciiUpper2Lower) == "hidden"):
+            # input type=hidden doesn't change framesetOK
+            self.parser.framesetOK = framesetOK
+
+    def startTagParamSource(self, token):
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
+        token["selfClosingAcknowledged"] = True
 
-        def endTagNoscript(self, token):
-            node = self.parser.tree.openElements.pop()
-            assert node.name == "noscript", "Expected noscript got %s" % node.name
-            self.parser.phase = self.parser.phases["inHead"]
+    def startTagHr(self, token):
+        if self.tree.elementInScope("p", variant="button"):
+            self.endTagP(impliedTagToken("p"))
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
+        token["selfClosingAcknowledged"] = True
+        self.parser.framesetOK = False
+
+    def startTagImage(self, token):
+        # No really...
+        self.parser.parseError("unexpected-start-tag-treated-as",
+                               {"originalName": "image", "newName": "img"})
+        self.processStartTag(impliedTagToken("img", "StartTag",
+                                             attributes=token["data"],
+                                             selfClosing=token["selfClosing"]))
+
+    def startTagIsIndex(self, token):
+        self.parser.parseError("deprecated-tag", {"name": "isindex"})
+        if self.tree.formPointer:
+            return
+        form_attrs = {}
+        if "action" in token["data"]:
+            form_attrs["action"] = token["data"]["action"]
+        self.processStartTag(impliedTagToken("form", "StartTag",
+                                             attributes=form_attrs))
+        self.processStartTag(impliedTagToken("hr", "StartTag"))
+        self.processStartTag(impliedTagToken("label", "StartTag"))
+        # XXX Localization ...
+        if "prompt" in token["data"]:
+            prompt = token["data"]["prompt"]
+        else:
+            prompt = "This is a searchable index. Enter search keywords: "
+        self.processCharacters(
+            {"type": tokenTypes["Characters"], "data": prompt})
+        attributes = token["data"].copy()
+        if "action" in attributes:
+            del attributes["action"]
+        if "prompt" in attributes:
+            del attributes["prompt"]
+        attributes["name"] = "isindex"
+        self.processStartTag(impliedTagToken("input", "StartTag",
+                                             attributes=attributes,
+                                             selfClosing=token["selfClosing"]))
+        self.processEndTag(impliedTagToken("label"))
+        self.processStartTag(impliedTagToken("hr", "StartTag"))
+        self.processEndTag(impliedTagToken("form"))
+
+    def startTagTextarea(self, token):
+        self.tree.insertElement(token)
+        self.parser.tokenizer.state = self.parser.tokenizer.rcdataState
+        self.processSpaceCharacters = self.processSpaceCharactersDropNewline
+        self.parser.framesetOK = False
 
-        def endTagBr(self, token):
-            self.parser.parseError("unexpected-inhead-noscript-tag", {"name": token["name"]})
-            self.anythingElse()
-            return token
+    def startTagIFrame(self, token):
+        self.parser.framesetOK = False
+        self.startTagRawtext(token)
 
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+    def startTagNoscript(self, token):
+        if self.parser.scripting:
+            self.startTagRawtext(token)
+        else:
+            self.startTagOther(token)
 
-        def anythingElse(self):
-            # Caller must raise parse error first!
-            self.endTagNoscript(impliedTagToken("noscript"))
+    def startTagRawtext(self, token):
+        """iframe, noembed noframes, noscript(if scripting enabled)"""
+        self.parser.parseRCDataRawtext(token, "RAWTEXT")
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml),
-            (("basefont", "bgsound", "link", "meta", "noframes", "style"), startTagBaseLinkCommand),
-            (("head", "noscript"), startTagHeadNoscript),
-        ])
-        startTagHandler.default = startTagOther
+    def startTagOpt(self, token):
+        if self.tree.openElements[-1].name == "option":
+            self.parser.phase.processEndTag(impliedTagToken("option"))
+        self.tree.reconstructActiveFormattingElements()
+        self.parser.tree.insertElement(token)
 
-        endTagHandler = _utils.MethodDispatcher([
-            ("noscript", endTagNoscript),
-            ("br", endTagBr),
-        ])
-        endTagHandler.default = endTagOther
+    def startTagSelect(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertElement(token)
+        self.parser.framesetOK = False
+        if self.parser.phase in (self.parser.phases["inTable"],
+                                 self.parser.phases["inCaption"],
+                                 self.parser.phases["inColumnGroup"],
+                                 self.parser.phases["inTableBody"],
+                                 self.parser.phases["inRow"],
+                                 self.parser.phases["inCell"]):
+            self.parser.phase = self.parser.phases["inSelectInTable"]
+        else:
+            self.parser.phase = self.parser.phases["inSelect"]
 
-    class AfterHeadPhase(Phase):
-        __slots__ = tuple()
+    def startTagRpRt(self, token):
+        if self.tree.elementInScope("ruby"):
+            self.tree.generateImpliedEndTags()
+            if self.tree.openElements[-1].name != "ruby":
+                self.parser.parseError()
+        self.tree.insertElement(token)
 
-        def processEOF(self):
-            self.anythingElse()
-            return True
+    def startTagMath(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.parser.adjustMathMLAttributes(token)
+        self.parser.adjustForeignAttributes(token)
+        token["namespace"] = namespaces["mathml"]
+        self.tree.insertElement(token)
+        # Need to get the parse error right for the case where the token
+        # has a namespace not equal to the xmlns attribute
+        if token["selfClosing"]:
+            self.tree.openElements.pop()
+            token["selfClosingAcknowledged"] = True
 
-        def processCharacters(self, token):
-            self.anythingElse()
-            return token
+    def startTagSvg(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.parser.adjustSVGAttributes(token)
+        self.parser.adjustForeignAttributes(token)
+        token["namespace"] = namespaces["svg"]
+        self.tree.insertElement(token)
+        # Need to get the parse error right for the case where the token
+        # has a namespace not equal to the xmlns attribute
+        if token["selfClosing"]:
+            self.tree.openElements.pop()
+            token["selfClosingAcknowledged"] = True
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def startTagMisplaced(self, token):
+        """ Elements that should be children of other elements that have a
+        different insertion mode; here they are ignored
+        "caption", "col", "colgroup", "frame", "frameset", "head",
+        "option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
+        "tr", "noscript"
+        """
+        self.parser.parseError("unexpected-start-tag-ignored", {"name": token["name"]})
 
-        def startTagBody(self, token):
-            self.parser.framesetOK = False
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inBody"]
+    def startTagOther(self, token):
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertElement(token)
 
-        def startTagFrameset(self, token):
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inFrameset"]
+    def endTagP(self, token):
+        if not self.tree.elementInScope("p", variant="button"):
+            self.startTagCloseP(impliedTagToken("p", "StartTag"))
+            self.parser.parseError("unexpected-end-tag", {"name": "p"})
+            self.endTagP(impliedTagToken("p", "EndTag"))
+        else:
+            self.tree.generateImpliedEndTags("p")
+            if self.tree.openElements[-1].name != "p":
+                self.parser.parseError("unexpected-end-tag", {"name": "p"})
+            node = self.tree.openElements.pop()
+            while node.name != "p":
+                node = self.tree.openElements.pop()
 
-        def startTagFromHead(self, token):
-            self.parser.parseError("unexpected-start-tag-out-of-my-head",
-                                   {"name": token["name"]})
-            self.tree.openElements.append(self.tree.headPointer)
-            self.parser.phases["inHead"].processStartTag(token)
-            for node in self.tree.openElements[::-1]:
-                if node.name == "head":
-                    self.tree.openElements.remove(node)
+    def endTagBody(self, token):
+        if not self.tree.elementInScope("body"):
+            self.parser.parseError()
+            return
+        elif self.tree.openElements[-1].name != "body":
+            for node in self.tree.openElements[2:]:
+                if node.name not in frozenset(("dd", "dt", "li", "optgroup",
+                                               "option", "p", "rp", "rt",
+                                               "tbody", "td", "tfoot",
+                                               "th", "thead", "tr", "body",
+                                               "html")):
+                    # Not sure this is the correct name for the parse error
+                    self.parser.parseError(
+                        "expected-one-end-tag-but-got-another",
+                        {"gotName": "body", "expectedName": node.name})
                     break
+        self.parser.phase = self.parser.phases["afterBody"]
 
-        def startTagHead(self, token):
-            self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
-
-        def startTagOther(self, token):
-            self.anythingElse()
+    def endTagHtml(self, token):
+        # We repeat the test for the body end tag token being ignored here
+        if self.tree.elementInScope("body"):
+            self.endTagBody(impliedTagToken("body"))
             return token
 
-        def endTagHtmlBodyBr(self, token):
-            self.anythingElse()
-            return token
+    def endTagBlock(self, token):
+        # Put us back in the right whitespace handling mode
+        if token["name"] == "pre":
+            self.processSpaceCharacters = self.processSpaceCharactersNonPre
+        inScope = self.tree.elementInScope(token["name"])
+        if inScope:
+            self.tree.generateImpliedEndTags()
+        if self.tree.openElements[-1].name != token["name"]:
+            self.parser.parseError("end-tag-too-early", {"name": token["name"]})
+        if inScope:
+            node = self.tree.openElements.pop()
+            while node.name != token["name"]:
+                node = self.tree.openElements.pop()
 
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+    def endTagForm(self, token):
+        node = self.tree.formPointer
+        self.tree.formPointer = None
+        if node is None or not self.tree.elementInScope(node):
+            self.parser.parseError("unexpected-end-tag",
+                                   {"name": "form"})
+        else:
+            self.tree.generateImpliedEndTags()
+            if self.tree.openElements[-1] != node:
+                self.parser.parseError("end-tag-too-early-ignored",
+                                       {"name": "form"})
+            self.tree.openElements.remove(node)
 
-        def anythingElse(self):
-            self.tree.insertElement(impliedTagToken("body", "StartTag"))
-            self.parser.phase = self.parser.phases["inBody"]
-            self.parser.framesetOK = True
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml),
-            ("body", startTagBody),
-            ("frameset", startTagFrameset),
-            (("base", "basefont", "bgsound", "link", "meta", "noframes", "script",
-              "style", "title"),
-             startTagFromHead),
-            ("head", startTagHead)
-        ])
-        startTagHandler.default = startTagOther
-        endTagHandler = _utils.MethodDispatcher([(("body", "html", "br"),
-                                                  endTagHtmlBodyBr)])
-        endTagHandler.default = endTagOther
-
-    class InBodyPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#parsing-main-inbody
-        # the really-really-really-very crazy mode
-        __slots__ = ("processSpaceCharacters",)
-
-        def __init__(self, *args, **kwargs):
-            super(InBodyPhase, self).__init__(*args, **kwargs)
-            # Set this to the default handler
-            self.processSpaceCharacters = self.processSpaceCharactersNonPre
+    def endTagListItem(self, token):
+        if token["name"] == "li":
+            variant = "list"
+        else:
+            variant = None
+        if not self.tree.elementInScope(token["name"], variant=variant):
+            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+        else:
+            self.tree.generateImpliedEndTags(exclude=token["name"])
+            if self.tree.openElements[-1].name != token["name"]:
+                self.parser.parseError(
+                    "end-tag-too-early",
+                    {"name": token["name"]})
+            node = self.tree.openElements.pop()
+            while node.name != token["name"]:
+                node = self.tree.openElements.pop()
 
-        def isMatchingFormattingElement(self, node1, node2):
-            return (node1.name == node2.name and
-                    node1.namespace == node2.namespace and
-                    node1.attributes == node2.attributes)
+    def endTagHeading(self, token):
+        for item in headingElements:
+            if self.tree.elementInScope(item):
+                self.tree.generateImpliedEndTags()
+                break
+        if self.tree.openElements[-1].name != token["name"]:
+            self.parser.parseError("end-tag-too-early", {"name": token["name"]})
 
-        # helper
-        def addFormattingElement(self, token):
-            self.tree.insertElement(token)
-            element = self.tree.openElements[-1]
+        for item in headingElements:
+            if self.tree.elementInScope(item):
+                item = self.tree.openElements.pop()
+                while item.name not in headingElements:
+                    item = self.tree.openElements.pop()
+                break
 
-            matchingElements = []
-            for node in self.tree.activeFormattingElements[::-1]:
-                if node is Marker:
-                    break
-                elif self.isMatchingFormattingElement(node, element):
-                    matchingElements.append(node)
-
-            assert len(matchingElements) <= 3
-            if len(matchingElements) == 3:
-                self.tree.activeFormattingElements.remove(matchingElements[-1])
-            self.tree.activeFormattingElements.append(element)
-
-        # the real deal
-        def processEOF(self):
-            allowed_elements = frozenset(("dd", "dt", "li", "p", "tbody", "td",
-                                          "tfoot", "th", "thead", "tr", "body",
-                                          "html"))
-            for node in self.tree.openElements[::-1]:
-                if node.name not in allowed_elements:
-                    self.parser.parseError("expected-closing-tag-but-got-eof")
-                    break
-            # Stop parsing
+    def endTagFormatting(self, token):
+        """The much-feared adoption agency algorithm"""
+        # http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867
+        # XXX Better parseError messages appreciated.
+
+        # Step 1
+        outerLoopCounter = 0
+
+        # Step 2
+        while outerLoopCounter < 8:
+
+            # Step 3
+            outerLoopCounter += 1
+
+            # Step 4:
+
+            # Let the formatting element be the last element in
+            # the list of active formatting elements that:
+            # - is between the end of the list and the last scope
+            # marker in the list, if any, or the start of the list
+            # otherwise, and
+            # - has the same tag name as the token.
+            formattingElement = self.tree.elementInActiveFormattingElements(
+                token["name"])
+            if (not formattingElement or
+                (formattingElement in self.tree.openElements and
+                 not self.tree.elementInScope(formattingElement.name))):
+                # If there is no such node, then abort these steps
+                # and instead act as described in the "any other
+                # end tag" entry below.
+                self.endTagOther(token)
+                return
 
-        def processSpaceCharactersDropNewline(self, token):
-            # Sometimes (start of <pre>, <listing>, and <textarea> blocks) we
-            # want to drop leading newlines
-            data = token["data"]
-            self.processSpaceCharacters = self.processSpaceCharactersNonPre
-            if (data.startswith("\n") and
-                self.tree.openElements[-1].name in ("pre", "listing", "textarea") and
-                    not self.tree.openElements[-1].hasContent()):
-                data = data[1:]
-            if data:
-                self.tree.reconstructActiveFormattingElements()
-                self.tree.insertText(data)
-
-        def processCharacters(self, token):
-            if token["data"] == "\u0000":
-                # The tokenizer should always emit null on its own
+            # Otherwise, if there is such a node, but that node is
+            # not in the stack of open elements, then this is a
+            # parse error; remove the element from the list, and
+            # abort these steps.
+            elif formattingElement not in self.tree.openElements:
+                self.parser.parseError("adoption-agency-1.2", {"name": token["name"]})
+                self.tree.activeFormattingElements.remove(formattingElement)
                 return
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertText(token["data"])
-            # This must be bad for performance
-            if (self.parser.framesetOK and
-                any(char not in spaceCharacters
-                    for char in token["data"])):
-                self.parser.framesetOK = False
-
-        def processSpaceCharactersNonPre(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertText(token["data"])
 
-        def startTagProcessInHead(self, token):
-            return self.parser.phases["inHead"].processStartTag(token)
+            # Otherwise, if there is such a node, and that node is
+            # also in the stack of open elements, but the element
+            # is not in scope, then this is a parse error; ignore
+            # the token, and abort these steps.
+            elif not self.tree.elementInScope(formattingElement.name):
+                self.parser.parseError("adoption-agency-4.4", {"name": token["name"]})
+                return
 
-        def startTagBody(self, token):
-            self.parser.parseError("unexpected-start-tag", {"name": "body"})
-            if (len(self.tree.openElements) == 1 or
-                    self.tree.openElements[1].name != "body"):
-                assert self.parser.innerHTML
-            else:
-                self.parser.framesetOK = False
-                for attr, value in token["data"].items():
-                    if attr not in self.tree.openElements[1].attributes:
-                        self.tree.openElements[1].attributes[attr] = value
-
-        def startTagFrameset(self, token):
-            self.parser.parseError("unexpected-start-tag", {"name": "frameset"})
-            if (len(self.tree.openElements) == 1 or self.tree.openElements[1].name != "body"):
-                assert self.parser.innerHTML
-            elif not self.parser.framesetOK:
-                pass
+            # Otherwise, there is a formatting element and that
+            # element is in the stack and is in scope. If the
+            # element is not the current node, this is a parse
+            # error. In any case, proceed with the algorithm as
+            # written in the following steps.
             else:
-                if self.tree.openElements[1].parent:
-                    self.tree.openElements[1].parent.removeChild(self.tree.openElements[1])
-                while self.tree.openElements[-1].name != "html":
-                    self.tree.openElements.pop()
-                self.tree.insertElement(token)
-                self.parser.phase = self.parser.phases["inFrameset"]
-
-        def startTagCloseP(self, token):
-            if self.tree.elementInScope("p", variant="button"):
-                self.endTagP(impliedTagToken("p"))
-            self.tree.insertElement(token)
+                if formattingElement != self.tree.openElements[-1]:
+                    self.parser.parseError("adoption-agency-1.3", {"name": token["name"]})
+
+            # Step 5:
+
+            # Let the furthest block be the topmost node in the
+            # stack of open elements that is lower in the stack
+            # than the formatting element, and is an element in
+            # the special category. There might not be one.
+            afeIndex = self.tree.openElements.index(formattingElement)
+            furthestBlock = None
+            for element in self.tree.openElements[afeIndex:]:
+                if element.nameTuple in specialElements:
+                    furthestBlock = element
+                    break
 
-        def startTagPreListing(self, token):
-            if self.tree.elementInScope("p", variant="button"):
-                self.endTagP(impliedTagToken("p"))
-            self.tree.insertElement(token)
-            self.parser.framesetOK = False
-            self.processSpaceCharacters = self.processSpaceCharactersDropNewline
+            # Step 6:
+
+            # If there is no furthest block, then the UA must
+            # first pop all the nodes from the bottom of the stack
+            # of open elements, from the current node up to and
+            # including the formatting element, then remove the
+            # formatting element from the list of active
+            # formatting elements, and finally abort these steps.
+            if furthestBlock is None:
+                element = self.tree.openElements.pop()
+                while element != formattingElement:
+                    element = self.tree.openElements.pop()
+                self.tree.activeFormattingElements.remove(element)
+                return
 
-        def startTagForm(self, token):
-            if self.tree.formPointer:
-                self.parser.parseError("unexpected-start-tag", {"name": "form"})
+            # Step 7
+            commonAncestor = self.tree.openElements[afeIndex - 1]
+
+            # Step 8:
+            # The bookmark is supposed to help us identify where to reinsert
+            # nodes in step 15. We have to ensure that we reinsert nodes after
+            # the node before the active formatting element. Note the bookmark
+            # can move in step 9.7
+            bookmark = self.tree.activeFormattingElements.index(formattingElement)
+
+            # Step 9
+            lastNode = node = furthestBlock
+            innerLoopCounter = 0
+
+            index = self.tree.openElements.index(node)
+            while innerLoopCounter < 3:
+                innerLoopCounter += 1
+                # Node is element before node in open elements
+                index -= 1
+                node = self.tree.openElements[index]
+                if node not in self.tree.activeFormattingElements:
+                    self.tree.openElements.remove(node)
+                    continue
+                # Step 9.6
+                if node == formattingElement:
+                    break
+                # Step 9.7
+                if lastNode == furthestBlock:
+                    bookmark = self.tree.activeFormattingElements.index(node) + 1
+                # Step 9.8
+                clone = node.cloneNode()
+                # Replace node with clone
+                self.tree.activeFormattingElements[
+                    self.tree.activeFormattingElements.index(node)] = clone
+                self.tree.openElements[
+                    self.tree.openElements.index(node)] = clone
+                node = clone
+                # Step 9.9
+                # Remove lastNode from its parents, if any
+                if lastNode.parent:
+                    lastNode.parent.removeChild(lastNode)
+                node.appendChild(lastNode)
+                # Step 9.10
+                lastNode = node
+
+            # Step 10
+            # Foster parent lastNode if commonAncestor is a
+            # table, tbody, tfoot, thead, or tr we need to foster
+            # parent the lastNode
+            if lastNode.parent:
+                lastNode.parent.removeChild(lastNode)
+
+            if commonAncestor.name in frozenset(("table", "tbody", "tfoot", "thead", "tr")):
+                parent, insertBefore = self.tree.getTableMisnestedNodePosition()
+                parent.insertBefore(lastNode, insertBefore)
             else:
-                if self.tree.elementInScope("p", variant="button"):
-                    self.endTagP(impliedTagToken("p"))
-                self.tree.insertElement(token)
-                self.tree.formPointer = self.tree.openElements[-1]
+                commonAncestor.appendChild(lastNode)
 
-        def startTagListItem(self, token):
-            self.parser.framesetOK = False
+            # Step 11
+            clone = formattingElement.cloneNode()
 
-            stopNamesMap = {"li": ["li"],
-                            "dt": ["dt", "dd"],
-                            "dd": ["dt", "dd"]}
-            stopNames = stopNamesMap[token["name"]]
-            for node in reversed(self.tree.openElements):
-                if node.name in stopNames:
-                    self.parser.phase.processEndTag(
-                        impliedTagToken(node.name, "EndTag"))
-                    break
-                if (node.nameTuple in specialElements and
-                        node.name not in ("address", "div", "p")):
-                    break
+            # Step 12
+            furthestBlock.reparentChildren(clone)
 
-            if self.tree.elementInScope("p", variant="button"):
-                self.parser.phase.processEndTag(
-                    impliedTagToken("p", "EndTag"))
+            # Step 13
+            furthestBlock.appendChild(clone)
 
-            self.tree.insertElement(token)
+            # Step 14
+            self.tree.activeFormattingElements.remove(formattingElement)
+            self.tree.activeFormattingElements.insert(bookmark, clone)
 
-        def startTagPlaintext(self, token):
-            if self.tree.elementInScope("p", variant="button"):
-                self.endTagP(impliedTagToken("p"))
-            self.tree.insertElement(token)
-            self.parser.tokenizer.state = self.parser.tokenizer.plaintextState
+            # Step 15
+            self.tree.openElements.remove(formattingElement)
+            self.tree.openElements.insert(
+                self.tree.openElements.index(furthestBlock) + 1, clone)
 
-        def startTagHeading(self, token):
-            if self.tree.elementInScope("p", variant="button"):
-                self.endTagP(impliedTagToken("p"))
-            if self.tree.openElements[-1].name in headingElements:
-                self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
-                self.tree.openElements.pop()
-            self.tree.insertElement(token)
+    def endTagAppletMarqueeObject(self, token):
+        if self.tree.elementInScope(token["name"]):
+            self.tree.generateImpliedEndTags()
+        if self.tree.openElements[-1].name != token["name"]:
+            self.parser.parseError("end-tag-too-early", {"name": token["name"]})
 
-        def startTagA(self, token):
-            afeAElement = self.tree.elementInActiveFormattingElements("a")
-            if afeAElement:
-                self.parser.parseError("unexpected-start-tag-implies-end-tag",
-                                       {"startName": "a", "endName": "a"})
-                self.endTagFormatting(impliedTagToken("a"))
-                if afeAElement in self.tree.openElements:
-                    self.tree.openElements.remove(afeAElement)
-                if afeAElement in self.tree.activeFormattingElements:
-                    self.tree.activeFormattingElements.remove(afeAElement)
-            self.tree.reconstructActiveFormattingElements()
-            self.addFormattingElement(token)
+        if self.tree.elementInScope(token["name"]):
+            element = self.tree.openElements.pop()
+            while element.name != token["name"]:
+                element = self.tree.openElements.pop()
+            self.tree.clearActiveFormattingElements()
 
-        def startTagFormatting(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.addFormattingElement(token)
+    def endTagBr(self, token):
+        self.parser.parseError("unexpected-end-tag-treated-as",
+                               {"originalName": "br", "newName": "br element"})
+        self.tree.reconstructActiveFormattingElements()
+        self.tree.insertElement(impliedTagToken("br", "StartTag"))
+        self.tree.openElements.pop()
 
-        def startTagNobr(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            if self.tree.elementInScope("nobr"):
-                self.parser.parseError("unexpected-start-tag-implies-end-tag",
-                                       {"startName": "nobr", "endName": "nobr"})
-                self.processEndTag(impliedTagToken("nobr"))
-                # XXX Need tests that trigger the following
-                self.tree.reconstructActiveFormattingElements()
-            self.addFormattingElement(token)
-
-        def startTagButton(self, token):
-            if self.tree.elementInScope("button"):
-                self.parser.parseError("unexpected-start-tag-implies-end-tag",
-                                       {"startName": "button", "endName": "button"})
-                self.processEndTag(impliedTagToken("button"))
-                return token
+    def endTagOther(self, token):
+        for node in self.tree.openElements[::-1]:
+            if node.name == token["name"]:
+                self.tree.generateImpliedEndTags(exclude=token["name"])
+                if self.tree.openElements[-1].name != token["name"]:
+                    self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+                while self.tree.openElements.pop() != node:
+                    pass
+                break
             else:
-                self.tree.reconstructActiveFormattingElements()
-                self.tree.insertElement(token)
-                self.parser.framesetOK = False
+                if node.nameTuple in specialElements:
+                    self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+                    break
 
-        def startTagAppletMarqueeObject(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertElement(token)
-            self.tree.activeFormattingElements.append(Marker)
-            self.parser.framesetOK = False
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        (("base", "basefont", "bgsound", "command", "link", "meta",
+          "script", "style", "title"),
+         startTagProcessInHead),
+        ("body", startTagBody),
+        ("frameset", startTagFrameset),
+        (("address", "article", "aside", "blockquote", "center", "details",
+          "dir", "div", "dl", "fieldset", "figcaption", "figure",
+          "footer", "header", "hgroup", "main", "menu", "nav", "ol", "p",
+          "section", "summary", "ul"),
+         startTagCloseP),
+        (headingElements, startTagHeading),
+        (("pre", "listing"), startTagPreListing),
+        ("form", startTagForm),
+        (("li", "dd", "dt"), startTagListItem),
+        ("plaintext", startTagPlaintext),
+        ("a", startTagA),
+        (("b", "big", "code", "em", "font", "i", "s", "small", "strike",
+          "strong", "tt", "u"), startTagFormatting),
+        ("nobr", startTagNobr),
+        ("button", startTagButton),
+        (("applet", "marquee", "object"), startTagAppletMarqueeObject),
+        ("xmp", startTagXmp),
+        ("table", startTagTable),
+        (("area", "br", "embed", "img", "keygen", "wbr"),
+         startTagVoidFormatting),
+        (("param", "source", "track"), startTagParamSource),
+        ("input", startTagInput),
+        ("hr", startTagHr),
+        ("image", startTagImage),
+        ("isindex", startTagIsIndex),
+        ("textarea", startTagTextarea),
+        ("iframe", startTagIFrame),
+        ("noscript", startTagNoscript),
+        (("noembed", "noframes"), startTagRawtext),
+        ("select", startTagSelect),
+        (("rp", "rt"), startTagRpRt),
+        (("option", "optgroup"), startTagOpt),
+        (("math"), startTagMath),
+        (("svg"), startTagSvg),
+        (("caption", "col", "colgroup", "frame", "head",
+          "tbody", "td", "tfoot", "th", "thead",
+          "tr"), startTagMisplaced)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("body", endTagBody),
+        ("html", endTagHtml),
+        (("address", "article", "aside", "blockquote", "button", "center",
+          "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure",
+          "footer", "header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre",
+          "section", "summary", "ul"), endTagBlock),
+        ("form", endTagForm),
+        ("p", endTagP),
+        (("dd", "dt", "li"), endTagListItem),
+        (headingElements, endTagHeading),
+        (("a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
+          "strike", "strong", "tt", "u"), endTagFormatting),
+        (("applet", "marquee", "object"), endTagAppletMarqueeObject),
+        ("br", endTagBr),
+    ])
+    endTagHandler.default = endTagOther
+
+
+class TextPhase(Phase):
+    __slots__ = tuple()
+
+    def processCharacters(self, token):
+        self.tree.insertText(token["data"])
+
+    def processEOF(self):
+        self.parser.parseError("expected-named-closing-tag-but-got-eof",
+                               {"name": self.tree.openElements[-1].name})
+        self.tree.openElements.pop()
+        self.parser.phase = self.parser.originalPhase
+        return True
+
+    def startTagOther(self, token):
+        assert False, "Tried to process start tag %s in RCDATA/RAWTEXT mode" % token['name']
+
+    def endTagScript(self, token):
+        node = self.tree.openElements.pop()
+        assert node.name == "script"
+        self.parser.phase = self.parser.originalPhase
+        # The rest of this method is all stuff that only happens if
+        # document.write works
+
+    def endTagOther(self, token):
+        self.tree.openElements.pop()
+        self.parser.phase = self.parser.originalPhase
+
+    startTagHandler = _utils.MethodDispatcher([])
+    startTagHandler.default = startTagOther
+    endTagHandler = _utils.MethodDispatcher([
+        ("script", endTagScript)])
+    endTagHandler.default = endTagOther
+
+
+class InTablePhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-table
+    __slots__ = tuple()
+
+    # helper methods
+    def clearStackToTableContext(self):
+        # "clear the stack back to a table context"
+        while self.tree.openElements[-1].name not in ("table", "html"):
+            # self.parser.parseError("unexpected-implied-end-tag-in-table",
+            #  {"name":  self.tree.openElements[-1].name})
+            self.tree.openElements.pop()
+        # When the current node is <html> it's an innerHTML case
 
-        def startTagXmp(self, token):
-            if self.tree.elementInScope("p", variant="button"):
-                self.endTagP(impliedTagToken("p"))
-            self.tree.reconstructActiveFormattingElements()
-            self.parser.framesetOK = False
-            self.parser.parseRCDataRawtext(token, "RAWTEXT")
+    # processing methods
+    def processEOF(self):
+        if self.tree.openElements[-1].name != "html":
+            self.parser.parseError("eof-in-table")
+        else:
+            assert self.parser.innerHTML
+        # Stop parsing
+
+    def processSpaceCharacters(self, token):
+        originalPhase = self.parser.phase
+        self.parser.phase = self.parser.phases["inTableText"]
+        self.parser.phase.originalPhase = originalPhase
+        self.parser.phase.processSpaceCharacters(token)
+
+    def processCharacters(self, token):
+        originalPhase = self.parser.phase
+        self.parser.phase = self.parser.phases["inTableText"]
+        self.parser.phase.originalPhase = originalPhase
+        self.parser.phase.processCharacters(token)
+
+    def insertText(self, token):
+        # If we get here there must be at least one non-whitespace character
+        # Do the table magic!
+        self.tree.insertFromTable = True
+        self.parser.phases["inBody"].processCharacters(token)
+        self.tree.insertFromTable = False
+
+    def startTagCaption(self, token):
+        self.clearStackToTableContext()
+        self.tree.activeFormattingElements.append(Marker)
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inCaption"]
 
-        def startTagTable(self, token):
-            if self.parser.compatMode != "quirks":
-                if self.tree.elementInScope("p", variant="button"):
-                    self.processEndTag(impliedTagToken("p"))
-            self.tree.insertElement(token)
-            self.parser.framesetOK = False
-            self.parser.phase = self.parser.phases["inTable"]
+    def startTagColgroup(self, token):
+        self.clearStackToTableContext()
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inColumnGroup"]
 
-        def startTagVoidFormatting(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertElement(token)
-            self.tree.openElements.pop()
-            token["selfClosingAcknowledged"] = True
-            self.parser.framesetOK = False
+    def startTagCol(self, token):
+        self.startTagColgroup(impliedTagToken("colgroup", "StartTag"))
+        return token
 
-        def startTagInput(self, token):
-            framesetOK = self.parser.framesetOK
-            self.startTagVoidFormatting(token)
-            if ("type" in token["data"] and
-                    token["data"]["type"].translate(asciiUpper2Lower) == "hidden"):
-                # input type=hidden doesn't change framesetOK
-                self.parser.framesetOK = framesetOK
+    def startTagRowGroup(self, token):
+        self.clearStackToTableContext()
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inTableBody"]
 
-        def startTagParamSource(self, token):
-            self.tree.insertElement(token)
-            self.tree.openElements.pop()
-            token["selfClosingAcknowledged"] = True
+    def startTagImplyTbody(self, token):
+        self.startTagRowGroup(impliedTagToken("tbody", "StartTag"))
+        return token
 
-        def startTagHr(self, token):
-            if self.tree.elementInScope("p", variant="button"):
-                self.endTagP(impliedTagToken("p"))
+    def startTagTable(self, token):
+        self.parser.parseError("unexpected-start-tag-implies-end-tag",
+                               {"startName": "table", "endName": "table"})
+        self.parser.phase.processEndTag(impliedTagToken("table"))
+        if not self.parser.innerHTML:
+            return token
+
+    def startTagStyleScript(self, token):
+        return self.parser.phases["inHead"].processStartTag(token)
+
+    def startTagInput(self, token):
+        if ("type" in token["data"] and
+                token["data"]["type"].translate(asciiUpper2Lower) == "hidden"):
+            self.parser.parseError("unexpected-hidden-input-in-table")
             self.tree.insertElement(token)
+            # XXX associate with form
             self.tree.openElements.pop()
-            token["selfClosingAcknowledged"] = True
-            self.parser.framesetOK = False
+        else:
+            self.startTagOther(token)
 
-        def startTagImage(self, token):
-            # No really...
-            self.parser.parseError("unexpected-start-tag-treated-as",
-                                   {"originalName": "image", "newName": "img"})
-            self.processStartTag(impliedTagToken("img", "StartTag",
-                                                 attributes=token["data"],
-                                                 selfClosing=token["selfClosing"]))
-
-        def startTagIsIndex(self, token):
-            self.parser.parseError("deprecated-tag", {"name": "isindex"})
-            if self.tree.formPointer:
-                return
-            form_attrs = {}
-            if "action" in token["data"]:
-                form_attrs["action"] = token["data"]["action"]
-            self.processStartTag(impliedTagToken("form", "StartTag",
-                                                 attributes=form_attrs))
-            self.processStartTag(impliedTagToken("hr", "StartTag"))
-            self.processStartTag(impliedTagToken("label", "StartTag"))
-            # XXX Localization ...
-            if "prompt" in token["data"]:
-                prompt = token["data"]["prompt"]
-            else:
-                prompt = "This is a searchable index. Enter search keywords: "
-            self.processCharacters(
-                {"type": tokenTypes["Characters"], "data": prompt})
-            attributes = token["data"].copy()
-            if "action" in attributes:
-                del attributes["action"]
-            if "prompt" in attributes:
-                del attributes["prompt"]
-            attributes["name"] = "isindex"
-            self.processStartTag(impliedTagToken("input", "StartTag",
-                                                 attributes=attributes,
-                                                 selfClosing=token["selfClosing"]))
-            self.processEndTag(impliedTagToken("label"))
-            self.processStartTag(impliedTagToken("hr", "StartTag"))
-            self.processEndTag(impliedTagToken("form"))
-
-        def startTagTextarea(self, token):
+    def startTagForm(self, token):
+        self.parser.parseError("unexpected-form-in-table")
+        if self.tree.formPointer is None:
             self.tree.insertElement(token)
-            self.parser.tokenizer.state = self.parser.tokenizer.rcdataState
-            self.processSpaceCharacters = self.processSpaceCharactersDropNewline
-            self.parser.framesetOK = False
+            self.tree.formPointer = self.tree.openElements[-1]
+            self.tree.openElements.pop()
 
-        def startTagIFrame(self, token):
-            self.parser.framesetOK = False
-            self.startTagRawtext(token)
+    def startTagOther(self, token):
+        self.parser.parseError("unexpected-start-tag-implies-table-voodoo", {"name": token["name"]})
+        # Do the table magic!
+        self.tree.insertFromTable = True
+        self.parser.phases["inBody"].processStartTag(token)
+        self.tree.insertFromTable = False
+
+    def endTagTable(self, token):
+        if self.tree.elementInScope("table", variant="table"):
+            self.tree.generateImpliedEndTags()
+            if self.tree.openElements[-1].name != "table":
+                self.parser.parseError("end-tag-too-early-named",
+                                       {"gotName": "table",
+                                        "expectedName": self.tree.openElements[-1].name})
+            while self.tree.openElements[-1].name != "table":
+                self.tree.openElements.pop()
+            self.tree.openElements.pop()
+            self.parser.resetInsertionMode()
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
+            self.parser.parseError()
 
-        def startTagNoscript(self, token):
-            if self.parser.scripting:
-                self.startTagRawtext(token)
-            else:
-                self.startTagOther(token)
+    def endTagIgnore(self, token):
+        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag-implies-table-voodoo", {"name": token["name"]})
+        # Do the table magic!
+        self.tree.insertFromTable = True
+        self.parser.phases["inBody"].processEndTag(token)
+        self.tree.insertFromTable = False
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        ("caption", startTagCaption),
+        ("colgroup", startTagColgroup),
+        ("col", startTagCol),
+        (("tbody", "tfoot", "thead"), startTagRowGroup),
+        (("td", "th", "tr"), startTagImplyTbody),
+        ("table", startTagTable),
+        (("style", "script"), startTagStyleScript),
+        ("input", startTagInput),
+        ("form", startTagForm)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("table", endTagTable),
+        (("body", "caption", "col", "colgroup", "html", "tbody", "td",
+          "tfoot", "th", "thead", "tr"), endTagIgnore)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class InTableTextPhase(Phase):
+    __slots__ = ("originalPhase", "characterTokens")
+
+    def __init__(self, *args, **kwargs):
+        super(InTableTextPhase, self).__init__(*args, **kwargs)
+        self.originalPhase = None
+        self.characterTokens = []
+
+    def flushCharacters(self):
+        data = "".join([item["data"] for item in self.characterTokens])
+        if any(item not in spaceCharacters for item in data):
+            token = {"type": tokenTypes["Characters"], "data": data}
+            self.parser.phases["inTable"].insertText(token)
+        elif data:
+            self.tree.insertText(data)
+        self.characterTokens = []
+
+    def processComment(self, token):
+        self.flushCharacters()
+        self.parser.phase = self.originalPhase
+        return token
+
+    def processEOF(self):
+        self.flushCharacters()
+        self.parser.phase = self.originalPhase
+        return True
+
+    def processCharacters(self, token):
+        if token["data"] == "\u0000":
+            return
+        self.characterTokens.append(token)
+
+    def processSpaceCharacters(self, token):
+        # pretty sure we should never reach here
+        self.characterTokens.append(token)
+#        assert False
+
+    def processStartTag(self, token):
+        self.flushCharacters()
+        self.parser.phase = self.originalPhase
+        return token
+
+    def processEndTag(self, token):
+        self.flushCharacters()
+        self.parser.phase = self.originalPhase
+        return token
+
+
+class InCaptionPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-caption
+    __slots__ = tuple()
+
+    def ignoreEndTagCaption(self):
+        return not self.tree.elementInScope("caption", variant="table")
+
+    def processEOF(self):
+        self.parser.phases["inBody"].processEOF()
+
+    def processCharacters(self, token):
+        return self.parser.phases["inBody"].processCharacters(token)
+
+    def startTagTableElement(self, token):
+        self.parser.parseError()
+        # XXX Have to duplicate logic here to find out if the tag is ignored
+        ignoreEndTag = self.ignoreEndTagCaption()
+        self.parser.phase.processEndTag(impliedTagToken("caption"))
+        if not ignoreEndTag:
+            return token
 
-        def startTagRawtext(self, token):
-            """iframe, noembed noframes, noscript(if scripting enabled)"""
-            self.parser.parseRCDataRawtext(token, "RAWTEXT")
-
-        def startTagOpt(self, token):
-            if self.tree.openElements[-1].name == "option":
-                self.parser.phase.processEndTag(impliedTagToken("option"))
-            self.tree.reconstructActiveFormattingElements()
-            self.parser.tree.insertElement(token)
-
-        def startTagSelect(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertElement(token)
-            self.parser.framesetOK = False
-            if self.parser.phase in (self.parser.phases["inTable"],
-                                     self.parser.phases["inCaption"],
-                                     self.parser.phases["inColumnGroup"],
-                                     self.parser.phases["inTableBody"],
-                                     self.parser.phases["inRow"],
-                                     self.parser.phases["inCell"]):
-                self.parser.phase = self.parser.phases["inSelectInTable"]
-            else:
-                self.parser.phase = self.parser.phases["inSelect"]
-
-        def startTagRpRt(self, token):
-            if self.tree.elementInScope("ruby"):
-                self.tree.generateImpliedEndTags()
-                if self.tree.openElements[-1].name != "ruby":
-                    self.parser.parseError()
-            self.tree.insertElement(token)
-
-        def startTagMath(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.parser.adjustMathMLAttributes(token)
-            self.parser.adjustForeignAttributes(token)
-            token["namespace"] = namespaces["mathml"]
-            self.tree.insertElement(token)
-            # Need to get the parse error right for the case where the token
-            # has a namespace not equal to the xmlns attribute
-            if token["selfClosing"]:
+    def startTagOther(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
+
+    def endTagCaption(self, token):
+        if not self.ignoreEndTagCaption():
+            # AT this code is quite similar to endTagTable in "InTable"
+            self.tree.generateImpliedEndTags()
+            if self.tree.openElements[-1].name != "caption":
+                self.parser.parseError("expected-one-end-tag-but-got-another",
+                                       {"gotName": "caption",
+                                        "expectedName": self.tree.openElements[-1].name})
+            while self.tree.openElements[-1].name != "caption":
                 self.tree.openElements.pop()
-                token["selfClosingAcknowledged"] = True
-
-        def startTagSvg(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.parser.adjustSVGAttributes(token)
-            self.parser.adjustForeignAttributes(token)
-            token["namespace"] = namespaces["svg"]
-            self.tree.insertElement(token)
-            # Need to get the parse error right for the case where the token
-            # has a namespace not equal to the xmlns attribute
-            if token["selfClosing"]:
-                self.tree.openElements.pop()
-                token["selfClosingAcknowledged"] = True
-
-        def startTagMisplaced(self, token):
-            """ Elements that should be children of other elements that have a
-            different insertion mode; here they are ignored
-            "caption", "col", "colgroup", "frame", "frameset", "head",
-            "option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
-            "tr", "noscript"
-            """
-            self.parser.parseError("unexpected-start-tag-ignored", {"name": token["name"]})
-
-        def startTagOther(self, token):
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertElement(token)
-
-        def endTagP(self, token):
-            if not self.tree.elementInScope("p", variant="button"):
-                self.startTagCloseP(impliedTagToken("p", "StartTag"))
-                self.parser.parseError("unexpected-end-tag", {"name": "p"})
-                self.endTagP(impliedTagToken("p", "EndTag"))
-            else:
-                self.tree.generateImpliedEndTags("p")
-                if self.tree.openElements[-1].name != "p":
-                    self.parser.parseError("unexpected-end-tag", {"name": "p"})
-                node = self.tree.openElements.pop()
-                while node.name != "p":
-                    node = self.tree.openElements.pop()
-
-        def endTagBody(self, token):
-            if not self.tree.elementInScope("body"):
-                self.parser.parseError()
-                return
-            elif self.tree.openElements[-1].name != "body":
-                for node in self.tree.openElements[2:]:
-                    if node.name not in frozenset(("dd", "dt", "li", "optgroup",
-                                                   "option", "p", "rp", "rt",
-                                                   "tbody", "td", "tfoot",
-                                                   "th", "thead", "tr", "body",
-                                                   "html")):
-                        # Not sure this is the correct name for the parse error
-                        self.parser.parseError(
-                            "expected-one-end-tag-but-got-another",
-                            {"gotName": "body", "expectedName": node.name})
-                        break
-            self.parser.phase = self.parser.phases["afterBody"]
-
-        def endTagHtml(self, token):
-            # We repeat the test for the body end tag token being ignored here
-            if self.tree.elementInScope("body"):
-                self.endTagBody(impliedTagToken("body"))
-                return token
-
-        def endTagBlock(self, token):
-            # Put us back in the right whitespace handling mode
-            if token["name"] == "pre":
-                self.processSpaceCharacters = self.processSpaceCharactersNonPre
-            inScope = self.tree.elementInScope(token["name"])
-            if inScope:
-                self.tree.generateImpliedEndTags()
-            if self.tree.openElements[-1].name != token["name"]:
-                self.parser.parseError("end-tag-too-early", {"name": token["name"]})
-            if inScope:
-                node = self.tree.openElements.pop()
-                while node.name != token["name"]:
-                    node = self.tree.openElements.pop()
-
-        def endTagForm(self, token):
-            node = self.tree.formPointer
-            self.tree.formPointer = None
-            if node is None or not self.tree.elementInScope(node):
-                self.parser.parseError("unexpected-end-tag",
-                                       {"name": "form"})
-            else:
-                self.tree.generateImpliedEndTags()
-                if self.tree.openElements[-1] != node:
-                    self.parser.parseError("end-tag-too-early-ignored",
-                                           {"name": "form"})
-                self.tree.openElements.remove(node)
-
-        def endTagListItem(self, token):
-            if token["name"] == "li":
-                variant = "list"
-            else:
-                variant = None
-            if not self.tree.elementInScope(token["name"], variant=variant):
-                self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
-            else:
-                self.tree.generateImpliedEndTags(exclude=token["name"])
-                if self.tree.openElements[-1].name != token["name"]:
-                    self.parser.parseError(
-                        "end-tag-too-early",
-                        {"name": token["name"]})
-                node = self.tree.openElements.pop()
-                while node.name != token["name"]:
-                    node = self.tree.openElements.pop()
-
-        def endTagHeading(self, token):
-            for item in headingElements:
-                if self.tree.elementInScope(item):
-                    self.tree.generateImpliedEndTags()
-                    break
-            if self.tree.openElements[-1].name != token["name"]:
-                self.parser.parseError("end-tag-too-early", {"name": token["name"]})
-
-            for item in headingElements:
-                if self.tree.elementInScope(item):
-                    item = self.tree.openElements.pop()
-                    while item.name not in headingElements:
-                        item = self.tree.openElements.pop()
-                    break
-
-        def endTagFormatting(self, token):
-            """The much-feared adoption agency algorithm"""
-            # http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867
-            # XXX Better parseError messages appreciated.
-
-            # Step 1
-            outerLoopCounter = 0
-
-            # Step 2
-            while outerLoopCounter < 8:
-
-                # Step 3
-                outerLoopCounter += 1
-
-                # Step 4:
-
-                # Let the formatting element be the last element in
-                # the list of active formatting elements that:
-                # - is between the end of the list and the last scope
-                # marker in the list, if any, or the start of the list
-                # otherwise, and
-                # - has the same tag name as the token.
-                formattingElement = self.tree.elementInActiveFormattingElements(
-                    token["name"])
-                if (not formattingElement or
-                    (formattingElement in self.tree.openElements and
-                     not self.tree.elementInScope(formattingElement.name))):
-                    # If there is no such node, then abort these steps
-                    # and instead act as described in the "any other
-                    # end tag" entry below.
-                    self.endTagOther(token)
-                    return
-
-                # Otherwise, if there is such a node, but that node is
-                # not in the stack of open elements, then this is a
-                # parse error; remove the element from the list, and
-                # abort these steps.
-                elif formattingElement not in self.tree.openElements:
-                    self.parser.parseError("adoption-agency-1.2", {"name": token["name"]})
-                    self.tree.activeFormattingElements.remove(formattingElement)
-                    return
-
-                # Otherwise, if there is such a node, and that node is
-                # also in the stack of open elements, but the element
-                # is not in scope, then this is a parse error; ignore
-                # the token, and abort these steps.
-                elif not self.tree.elementInScope(formattingElement.name):
-                    self.parser.parseError("adoption-agency-4.4", {"name": token["name"]})
-                    return
-
-                # Otherwise, there is a formatting element and that
-                # element is in the stack and is in scope. If the
-                # element is not the current node, this is a parse
-                # error. In any case, proceed with the algorithm as
-                # written in the following steps.
-                else:
-                    if formattingElement != self.tree.openElements[-1]:
-                        self.parser.parseError("adoption-agency-1.3", {"name": token["name"]})
-
-                # Step 5:
-
-                # Let the furthest block be the topmost node in the
-                # stack of open elements that is lower in the stack
-                # than the formatting element, and is an element in
-                # the special category. There might not be one.
-                afeIndex = self.tree.openElements.index(formattingElement)
-                furthestBlock = None
-                for element in self.tree.openElements[afeIndex:]:
-                    if element.nameTuple in specialElements:
-                        furthestBlock = element
-                        break
-
-                # Step 6:
-
-                # If there is no furthest block, then the UA must
-                # first pop all the nodes from the bottom of the stack
-                # of open elements, from the current node up to and
-                # including the formatting element, then remove the
-                # formatting element from the list of active
-                # formatting elements, and finally abort these steps.
-                if furthestBlock is None:
-                    element = self.tree.openElements.pop()
-                    while element != formattingElement:
-                        element = self.tree.openElements.pop()
-                    self.tree.activeFormattingElements.remove(element)
-                    return
-
-                # Step 7
-                commonAncestor = self.tree.openElements[afeIndex - 1]
-
-                # Step 8:
-                # The bookmark is supposed to help us identify where to reinsert
-                # nodes in step 15. We have to ensure that we reinsert nodes after
-                # the node before the active formatting element. Note the bookmark
-                # can move in step 9.7
-                bookmark = self.tree.activeFormattingElements.index(formattingElement)
-
-                # Step 9
-                lastNode = node = furthestBlock
-                innerLoopCounter = 0
-
-                index = self.tree.openElements.index(node)
-                while innerLoopCounter < 3:
-                    innerLoopCounter += 1
-                    # Node is element before node in open elements
-                    index -= 1
-                    node = self.tree.openElements[index]
-                    if node not in self.tree.activeFormattingElements:
-                        self.tree.openElements.remove(node)
-                        continue
-                    # Step 9.6
-                    if node == formattingElement:
-                        break
-                    # Step 9.7
-                    if lastNode == furthestBlock:
-                        bookmark = self.tree.activeFormattingElements.index(node) + 1
-                    # Step 9.8
-                    clone = node.cloneNode()
-                    # Replace node with clone
-                    self.tree.activeFormattingElements[
-                        self.tree.activeFormattingElements.index(node)] = clone
-                    self.tree.openElements[
-                        self.tree.openElements.index(node)] = clone
-                    node = clone
-                    # Step 9.9
-                    # Remove lastNode from its parents, if any
-                    if lastNode.parent:
-                        lastNode.parent.removeChild(lastNode)
-                    node.appendChild(lastNode)
-                    # Step 9.10
-                    lastNode = node
-
-                # Step 10
-                # Foster parent lastNode if commonAncestor is a
-                # table, tbody, tfoot, thead, or tr we need to foster
-                # parent the lastNode
-                if lastNode.parent:
-                    lastNode.parent.removeChild(lastNode)
-
-                if commonAncestor.name in frozenset(("table", "tbody", "tfoot", "thead", "tr")):
-                    parent, insertBefore = self.tree.getTableMisnestedNodePosition()
-                    parent.insertBefore(lastNode, insertBefore)
-                else:
-                    commonAncestor.appendChild(lastNode)
-
-                # Step 11
-                clone = formattingElement.cloneNode()
-
-                # Step 12
-                furthestBlock.reparentChildren(clone)
-
-                # Step 13
-                furthestBlock.appendChild(clone)
-
-                # Step 14
-                self.tree.activeFormattingElements.remove(formattingElement)
-                self.tree.activeFormattingElements.insert(bookmark, clone)
-
-                # Step 15
-                self.tree.openElements.remove(formattingElement)
-                self.tree.openElements.insert(
-                    self.tree.openElements.index(furthestBlock) + 1, clone)
-
-        def endTagAppletMarqueeObject(self, token):
-            if self.tree.elementInScope(token["name"]):
-                self.tree.generateImpliedEndTags()
-            if self.tree.openElements[-1].name != token["name"]:
-                self.parser.parseError("end-tag-too-early", {"name": token["name"]})
-
-            if self.tree.elementInScope(token["name"]):
-                element = self.tree.openElements.pop()
-                while element.name != token["name"]:
-                    element = self.tree.openElements.pop()
-                self.tree.clearActiveFormattingElements()
-
-        def endTagBr(self, token):
-            self.parser.parseError("unexpected-end-tag-treated-as",
-                                   {"originalName": "br", "newName": "br element"})
-            self.tree.reconstructActiveFormattingElements()
-            self.tree.insertElement(impliedTagToken("br", "StartTag"))
             self.tree.openElements.pop()
+            self.tree.clearActiveFormattingElements()
+            self.parser.phase = self.parser.phases["inTable"]
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
+            self.parser.parseError()
 
-        def endTagOther(self, token):
-            for node in self.tree.openElements[::-1]:
-                if node.name == token["name"]:
-                    self.tree.generateImpliedEndTags(exclude=token["name"])
-                    if self.tree.openElements[-1].name != token["name"]:
-                        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
-                    while self.tree.openElements.pop() != node:
-                        pass
-                    break
-                else:
-                    if node.nameTuple in specialElements:
-                        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
-                        break
+    def endTagTable(self, token):
+        self.parser.parseError()
+        ignoreEndTag = self.ignoreEndTagCaption()
+        self.parser.phase.processEndTag(impliedTagToken("caption"))
+        if not ignoreEndTag:
+            return token
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            (("base", "basefont", "bgsound", "command", "link", "meta",
-              "script", "style", "title"),
-             startTagProcessInHead),
-            ("body", startTagBody),
-            ("frameset", startTagFrameset),
-            (("address", "article", "aside", "blockquote", "center", "details",
-              "dir", "div", "dl", "fieldset", "figcaption", "figure",
-              "footer", "header", "hgroup", "main", "menu", "nav", "ol", "p",
-              "section", "summary", "ul"),
-             startTagCloseP),
-            (headingElements, startTagHeading),
-            (("pre", "listing"), startTagPreListing),
-            ("form", startTagForm),
-            (("li", "dd", "dt"), startTagListItem),
-            ("plaintext", startTagPlaintext),
-            ("a", startTagA),
-            (("b", "big", "code", "em", "font", "i", "s", "small", "strike",
-              "strong", "tt", "u"), startTagFormatting),
-            ("nobr", startTagNobr),
-            ("button", startTagButton),
-            (("applet", "marquee", "object"), startTagAppletMarqueeObject),
-            ("xmp", startTagXmp),
-            ("table", startTagTable),
-            (("area", "br", "embed", "img", "keygen", "wbr"),
-             startTagVoidFormatting),
-            (("param", "source", "track"), startTagParamSource),
-            ("input", startTagInput),
-            ("hr", startTagHr),
-            ("image", startTagImage),
-            ("isindex", startTagIsIndex),
-            ("textarea", startTagTextarea),
-            ("iframe", startTagIFrame),
-            ("noscript", startTagNoscript),
-            (("noembed", "noframes"), startTagRawtext),
-            ("select", startTagSelect),
-            (("rp", "rt"), startTagRpRt),
-            (("option", "optgroup"), startTagOpt),
-            (("math"), startTagMath),
-            (("svg"), startTagSvg),
-            (("caption", "col", "colgroup", "frame", "head",
-              "tbody", "td", "tfoot", "th", "thead",
-              "tr"), startTagMisplaced)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("body", endTagBody),
-            ("html", endTagHtml),
-            (("address", "article", "aside", "blockquote", "button", "center",
-              "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure",
-              "footer", "header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre",
-              "section", "summary", "ul"), endTagBlock),
-            ("form", endTagForm),
-            ("p", endTagP),
-            (("dd", "dt", "li"), endTagListItem),
-            (headingElements, endTagHeading),
-            (("a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
-              "strike", "strong", "tt", "u"), endTagFormatting),
-            (("applet", "marquee", "object"), endTagAppletMarqueeObject),
-            ("br", endTagBr),
-        ])
-        endTagHandler.default = endTagOther
-
-    class TextPhase(Phase):
-        __slots__ = tuple()
-
-        def processCharacters(self, token):
-            self.tree.insertText(token["data"])
-
-        def processEOF(self):
-            self.parser.parseError("expected-named-closing-tag-but-got-eof",
-                                   {"name": self.tree.openElements[-1].name})
-            self.tree.openElements.pop()
-            self.parser.phase = self.parser.originalPhase
-            return True
+    def endTagIgnore(self, token):
+        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
 
-        def startTagOther(self, token):
-            assert False, "Tried to process start tag %s in RCDATA/RAWTEXT mode" % token['name']
+    def endTagOther(self, token):
+        return self.parser.phases["inBody"].processEndTag(token)
 
-        def endTagScript(self, token):
-            node = self.tree.openElements.pop()
-            assert node.name == "script"
-            self.parser.phase = self.parser.originalPhase
-            # The rest of this method is all stuff that only happens if
-            # document.write works
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
+          "thead", "tr"), startTagTableElement)
+    ])
+    startTagHandler.default = startTagOther
 
-        def endTagOther(self, token):
-            self.tree.openElements.pop()
-            self.parser.phase = self.parser.originalPhase
-
-        startTagHandler = _utils.MethodDispatcher([])
-        startTagHandler.default = startTagOther
-        endTagHandler = _utils.MethodDispatcher([
-            ("script", endTagScript)])
-        endTagHandler.default = endTagOther
-
-    class InTablePhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-table
-        __slots__ = tuple()
-
-        # helper methods
-        def clearStackToTableContext(self):
-            # "clear the stack back to a table context"
-            while self.tree.openElements[-1].name not in ("table", "html"):
-                # self.parser.parseError("unexpected-implied-end-tag-in-table",
-                #  {"name":  self.tree.openElements[-1].name})
-                self.tree.openElements.pop()
-            # When the current node is <html> it's an innerHTML case
+    endTagHandler = _utils.MethodDispatcher([
+        ("caption", endTagCaption),
+        ("table", endTagTable),
+        (("body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
+          "thead", "tr"), endTagIgnore)
+    ])
+    endTagHandler.default = endTagOther
 
-        # processing methods
-        def processEOF(self):
-            if self.tree.openElements[-1].name != "html":
-                self.parser.parseError("eof-in-table")
-            else:
-                assert self.parser.innerHTML
-            # Stop parsing
-
-        def processSpaceCharacters(self, token):
-            originalPhase = self.parser.phase
-            self.parser.phase = self.parser.phases["inTableText"]
-            self.parser.phase.originalPhase = originalPhase
-            self.parser.phase.processSpaceCharacters(token)
-
-        def processCharacters(self, token):
-            originalPhase = self.parser.phase
-            self.parser.phase = self.parser.phases["inTableText"]
-            self.parser.phase.originalPhase = originalPhase
-            self.parser.phase.processCharacters(token)
-
-        def insertText(self, token):
-            # If we get here there must be at least one non-whitespace character
-            # Do the table magic!
-            self.tree.insertFromTable = True
-            self.parser.phases["inBody"].processCharacters(token)
-            self.tree.insertFromTable = False
-
-        def startTagCaption(self, token):
-            self.clearStackToTableContext()
-            self.tree.activeFormattingElements.append(Marker)
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inCaption"]
 
-        def startTagColgroup(self, token):
-            self.clearStackToTableContext()
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inColumnGroup"]
+class InColumnGroupPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-column
+    __slots__ = tuple()
 
-        def startTagCol(self, token):
-            self.startTagColgroup(impliedTagToken("colgroup", "StartTag"))
-            return token
+    def ignoreEndTagColgroup(self):
+        return self.tree.openElements[-1].name == "html"
 
-        def startTagRowGroup(self, token):
-            self.clearStackToTableContext()
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inTableBody"]
+    def processEOF(self):
+        if self.tree.openElements[-1].name == "html":
+            assert self.parser.innerHTML
+            return
+        else:
+            ignoreEndTag = self.ignoreEndTagColgroup()
+            self.endTagColgroup(impliedTagToken("colgroup"))
+            if not ignoreEndTag:
+                return True
 
-        def startTagImplyTbody(self, token):
-            self.startTagRowGroup(impliedTagToken("tbody", "StartTag"))
+    def processCharacters(self, token):
+        ignoreEndTag = self.ignoreEndTagColgroup()
+        self.endTagColgroup(impliedTagToken("colgroup"))
+        if not ignoreEndTag:
             return token
 
-        def startTagTable(self, token):
-            self.parser.parseError("unexpected-start-tag-implies-end-tag",
-                                   {"startName": "table", "endName": "table"})
-            self.parser.phase.processEndTag(impliedTagToken("table"))
-            if not self.parser.innerHTML:
-                return token
-
-        def startTagStyleScript(self, token):
-            return self.parser.phases["inHead"].processStartTag(token)
-
-        def startTagInput(self, token):
-            if ("type" in token["data"] and
-                    token["data"]["type"].translate(asciiUpper2Lower) == "hidden"):
-                self.parser.parseError("unexpected-hidden-input-in-table")
-                self.tree.insertElement(token)
-                # XXX associate with form
-                self.tree.openElements.pop()
-            else:
-                self.startTagOther(token)
-
-        def startTagForm(self, token):
-            self.parser.parseError("unexpected-form-in-table")
-            if self.tree.formPointer is None:
-                self.tree.insertElement(token)
-                self.tree.formPointer = self.tree.openElements[-1]
-                self.tree.openElements.pop()
-
-        def startTagOther(self, token):
-            self.parser.parseError("unexpected-start-tag-implies-table-voodoo", {"name": token["name"]})
-            # Do the table magic!
-            self.tree.insertFromTable = True
-            self.parser.phases["inBody"].processStartTag(token)
-            self.tree.insertFromTable = False
-
-        def endTagTable(self, token):
-            if self.tree.elementInScope("table", variant="table"):
-                self.tree.generateImpliedEndTags()
-                if self.tree.openElements[-1].name != "table":
-                    self.parser.parseError("end-tag-too-early-named",
-                                           {"gotName": "table",
-                                            "expectedName": self.tree.openElements[-1].name})
-                while self.tree.openElements[-1].name != "table":
-                    self.tree.openElements.pop()
-                self.tree.openElements.pop()
-                self.parser.resetInsertionMode()
-            else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
-
-        def endTagIgnore(self, token):
-            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+    def startTagCol(self, token):
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
+        token["selfClosingAcknowledged"] = True
 
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag-implies-table-voodoo", {"name": token["name"]})
-            # Do the table magic!
-            self.tree.insertFromTable = True
-            self.parser.phases["inBody"].processEndTag(token)
-            self.tree.insertFromTable = False
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            ("caption", startTagCaption),
-            ("colgroup", startTagColgroup),
-            ("col", startTagCol),
-            (("tbody", "tfoot", "thead"), startTagRowGroup),
-            (("td", "th", "tr"), startTagImplyTbody),
-            ("table", startTagTable),
-            (("style", "script"), startTagStyleScript),
-            ("input", startTagInput),
-            ("form", startTagForm)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("table", endTagTable),
-            (("body", "caption", "col", "colgroup", "html", "tbody", "td",
-              "tfoot", "th", "thead", "tr"), endTagIgnore)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InTableTextPhase(Phase):
-        __slots__ = ("originalPhase", "characterTokens")
-
-        def __init__(self, *args, **kwargs):
-            super(InTableTextPhase, self).__init__(*args, **kwargs)
-            self.originalPhase = None
-            self.characterTokens = []
-
-        def flushCharacters(self):
-            data = "".join([item["data"] for item in self.characterTokens])
-            if any(item not in spaceCharacters for item in data):
-                token = {"type": tokenTypes["Characters"], "data": data}
-                self.parser.phases["inTable"].insertText(token)
-            elif data:
-                self.tree.insertText(data)
-            self.characterTokens = []
-
-        def processComment(self, token):
-            self.flushCharacters()
-            self.parser.phase = self.originalPhase
+    def startTagOther(self, token):
+        ignoreEndTag = self.ignoreEndTagColgroup()
+        self.endTagColgroup(impliedTagToken("colgroup"))
+        if not ignoreEndTag:
             return token
 
-        def processEOF(self):
-            self.flushCharacters()
-            self.parser.phase = self.originalPhase
-            return True
-
-        def processCharacters(self, token):
-            if token["data"] == "\u0000":
-                return
-            self.characterTokens.append(token)
-
-        def processSpaceCharacters(self, token):
-            # pretty sure we should never reach here
-            self.characterTokens.append(token)
-    #        assert False
+    def endTagColgroup(self, token):
+        if self.ignoreEndTagColgroup():
+            # innerHTML case
+            assert self.parser.innerHTML
+            self.parser.parseError()
+        else:
+            self.tree.openElements.pop()
+            self.parser.phase = self.parser.phases["inTable"]
 
-        def processStartTag(self, token):
-            self.flushCharacters()
-            self.parser.phase = self.originalPhase
-            return token
+    def endTagCol(self, token):
+        self.parser.parseError("no-end-tag", {"name": "col"})
 
-        def processEndTag(self, token):
-            self.flushCharacters()
-            self.parser.phase = self.originalPhase
+    def endTagOther(self, token):
+        ignoreEndTag = self.ignoreEndTagColgroup()
+        self.endTagColgroup(impliedTagToken("colgroup"))
+        if not ignoreEndTag:
             return token
 
-    class InCaptionPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-caption
-        __slots__ = tuple()
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        ("col", startTagCol)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("colgroup", endTagColgroup),
+        ("col", endTagCol)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class InTableBodyPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-table0
+    __slots__ = tuple()
+
+    # helper methods
+    def clearStackToTableBodyContext(self):
+        while self.tree.openElements[-1].name not in ("tbody", "tfoot",
+                                                      "thead", "html"):
+            # self.parser.parseError("unexpected-implied-end-tag-in-table",
+            #  {"name": self.tree.openElements[-1].name})
+            self.tree.openElements.pop()
+        if self.tree.openElements[-1].name == "html":
+            assert self.parser.innerHTML
 
-        def ignoreEndTagCaption(self):
-            return not self.tree.elementInScope("caption", variant="table")
+    # the rest
+    def processEOF(self):
+        self.parser.phases["inTable"].processEOF()
 
-        def processEOF(self):
-            self.parser.phases["inBody"].processEOF()
+    def processSpaceCharacters(self, token):
+        return self.parser.phases["inTable"].processSpaceCharacters(token)
 
-        def processCharacters(self, token):
-            return self.parser.phases["inBody"].processCharacters(token)
+    def processCharacters(self, token):
+        return self.parser.phases["inTable"].processCharacters(token)
 
-        def startTagTableElement(self, token):
+    def startTagTr(self, token):
+        self.clearStackToTableBodyContext()
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inRow"]
+
+    def startTagTableCell(self, token):
+        self.parser.parseError("unexpected-cell-in-table-body",
+                               {"name": token["name"]})
+        self.startTagTr(impliedTagToken("tr", "StartTag"))
+        return token
+
+    def startTagTableOther(self, token):
+        # XXX AT Any ideas on how to share this with endTagTable?
+        if (self.tree.elementInScope("tbody", variant="table") or
+            self.tree.elementInScope("thead", variant="table") or
+                self.tree.elementInScope("tfoot", variant="table")):
+            self.clearStackToTableBodyContext()
+            self.endTagTableRowGroup(
+                impliedTagToken(self.tree.openElements[-1].name))
+            return token
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
             self.parser.parseError()
-            # XXX Have to duplicate logic here to find out if the tag is ignored
-            ignoreEndTag = self.ignoreEndTagCaption()
-            self.parser.phase.processEndTag(impliedTagToken("caption"))
-            if not ignoreEndTag:
-                return token
 
-        def startTagOther(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def startTagOther(self, token):
+        return self.parser.phases["inTable"].processStartTag(token)
 
-        def endTagCaption(self, token):
-            if not self.ignoreEndTagCaption():
-                # AT this code is quite similar to endTagTable in "InTable"
-                self.tree.generateImpliedEndTags()
-                if self.tree.openElements[-1].name != "caption":
-                    self.parser.parseError("expected-one-end-tag-but-got-another",
-                                           {"gotName": "caption",
-                                            "expectedName": self.tree.openElements[-1].name})
-                while self.tree.openElements[-1].name != "caption":
-                    self.tree.openElements.pop()
-                self.tree.openElements.pop()
-                self.tree.clearActiveFormattingElements()
-                self.parser.phase = self.parser.phases["inTable"]
-            else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
+    def endTagTableRowGroup(self, token):
+        if self.tree.elementInScope(token["name"], variant="table"):
+            self.clearStackToTableBodyContext()
+            self.tree.openElements.pop()
+            self.parser.phase = self.parser.phases["inTable"]
+        else:
+            self.parser.parseError("unexpected-end-tag-in-table-body",
+                                   {"name": token["name"]})
 
-        def endTagTable(self, token):
+    def endTagTable(self, token):
+        if (self.tree.elementInScope("tbody", variant="table") or
+            self.tree.elementInScope("thead", variant="table") or
+                self.tree.elementInScope("tfoot", variant="table")):
+            self.clearStackToTableBodyContext()
+            self.endTagTableRowGroup(
+                impliedTagToken(self.tree.openElements[-1].name))
+            return token
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
             self.parser.parseError()
-            ignoreEndTag = self.ignoreEndTagCaption()
-            self.parser.phase.processEndTag(impliedTagToken("caption"))
-            if not ignoreEndTag:
-                return token
-
-        def endTagIgnore(self, token):
-            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
-
-        def endTagOther(self, token):
-            return self.parser.phases["inBody"].processEndTag(token)
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
-              "thead", "tr"), startTagTableElement)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("caption", endTagCaption),
-            ("table", endTagTable),
-            (("body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
-              "thead", "tr"), endTagIgnore)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InColumnGroupPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-column
-        __slots__ = tuple()
-
-        def ignoreEndTagColgroup(self):
-            return self.tree.openElements[-1].name == "html"
-
-        def processEOF(self):
-            if self.tree.openElements[-1].name == "html":
-                assert self.parser.innerHTML
-                return
-            else:
-                ignoreEndTag = self.ignoreEndTagColgroup()
-                self.endTagColgroup(impliedTagToken("colgroup"))
-                if not ignoreEndTag:
-                    return True
 
-        def processCharacters(self, token):
-            ignoreEndTag = self.ignoreEndTagColgroup()
-            self.endTagColgroup(impliedTagToken("colgroup"))
-            if not ignoreEndTag:
-                return token
-
-        def startTagCol(self, token):
-            self.tree.insertElement(token)
+    def endTagIgnore(self, token):
+        self.parser.parseError("unexpected-end-tag-in-table-body",
+                               {"name": token["name"]})
+
+    def endTagOther(self, token):
+        return self.parser.phases["inTable"].processEndTag(token)
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        ("tr", startTagTr),
+        (("td", "th"), startTagTableCell),
+        (("caption", "col", "colgroup", "tbody", "tfoot", "thead"),
+         startTagTableOther)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        (("tbody", "tfoot", "thead"), endTagTableRowGroup),
+        ("table", endTagTable),
+        (("body", "caption", "col", "colgroup", "html", "td", "th",
+          "tr"), endTagIgnore)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class InRowPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-row
+    __slots__ = tuple()
+
+    # helper methods (XXX unify this with other table helper methods)
+    def clearStackToTableRowContext(self):
+        while self.tree.openElements[-1].name not in ("tr", "html"):
+            self.parser.parseError("unexpected-implied-end-tag-in-table-row",
+                                   {"name": self.tree.openElements[-1].name})
             self.tree.openElements.pop()
-            token["selfClosingAcknowledged"] = True
 
-        def startTagOther(self, token):
-            ignoreEndTag = self.ignoreEndTagColgroup()
-            self.endTagColgroup(impliedTagToken("colgroup"))
-            if not ignoreEndTag:
-                return token
+    def ignoreEndTagTr(self):
+        return not self.tree.elementInScope("tr", variant="table")
 
-        def endTagColgroup(self, token):
-            if self.ignoreEndTagColgroup():
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
-            else:
-                self.tree.openElements.pop()
-                self.parser.phase = self.parser.phases["inTable"]
+    # the rest
+    def processEOF(self):
+        self.parser.phases["inTable"].processEOF()
 
-        def endTagCol(self, token):
-            self.parser.parseError("no-end-tag", {"name": "col"})
+    def processSpaceCharacters(self, token):
+        return self.parser.phases["inTable"].processSpaceCharacters(token)
 
-        def endTagOther(self, token):
-            ignoreEndTag = self.ignoreEndTagColgroup()
-            self.endTagColgroup(impliedTagToken("colgroup"))
-            if not ignoreEndTag:
-                return token
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            ("col", startTagCol)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("colgroup", endTagColgroup),
-            ("col", endTagCol)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InTableBodyPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-table0
-        __slots__ = tuple()
-
-        # helper methods
-        def clearStackToTableBodyContext(self):
-            while self.tree.openElements[-1].name not in ("tbody", "tfoot",
-                                                          "thead", "html"):
-                # self.parser.parseError("unexpected-implied-end-tag-in-table",
-                #  {"name": self.tree.openElements[-1].name})
-                self.tree.openElements.pop()
-            if self.tree.openElements[-1].name == "html":
-                assert self.parser.innerHTML
+    def processCharacters(self, token):
+        return self.parser.phases["inTable"].processCharacters(token)
 
-        # the rest
-        def processEOF(self):
-            self.parser.phases["inTable"].processEOF()
+    def startTagTableCell(self, token):
+        self.clearStackToTableRowContext()
+        self.tree.insertElement(token)
+        self.parser.phase = self.parser.phases["inCell"]
+        self.tree.activeFormattingElements.append(Marker)
+
+    def startTagTableOther(self, token):
+        ignoreEndTag = self.ignoreEndTagTr()
+        self.endTagTr(impliedTagToken("tr"))
+        # XXX how are we sure it's always ignored in the innerHTML case?
+        if not ignoreEndTag:
+            return token
 
-        def processSpaceCharacters(self, token):
-            return self.parser.phases["inTable"].processSpaceCharacters(token)
+    def startTagOther(self, token):
+        return self.parser.phases["inTable"].processStartTag(token)
 
-        def processCharacters(self, token):
-            return self.parser.phases["inTable"].processCharacters(token)
+    def endTagTr(self, token):
+        if not self.ignoreEndTagTr():
+            self.clearStackToTableRowContext()
+            self.tree.openElements.pop()
+            self.parser.phase = self.parser.phases["inTableBody"]
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
+            self.parser.parseError()
 
-        def startTagTr(self, token):
-            self.clearStackToTableBodyContext()
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inRow"]
+    def endTagTable(self, token):
+        ignoreEndTag = self.ignoreEndTagTr()
+        self.endTagTr(impliedTagToken("tr"))
+        # Reprocess the current tag if the tr end tag was not ignored
+        # XXX how are we sure it's always ignored in the innerHTML case?
+        if not ignoreEndTag:
+            return token
 
-        def startTagTableCell(self, token):
-            self.parser.parseError("unexpected-cell-in-table-body",
-                                   {"name": token["name"]})
-            self.startTagTr(impliedTagToken("tr", "StartTag"))
+    def endTagTableRowGroup(self, token):
+        if self.tree.elementInScope(token["name"], variant="table"):
+            self.endTagTr(impliedTagToken("tr"))
             return token
+        else:
+            self.parser.parseError()
 
-        def startTagTableOther(self, token):
-            # XXX AT Any ideas on how to share this with endTagTable?
-            if (self.tree.elementInScope("tbody", variant="table") or
-                self.tree.elementInScope("thead", variant="table") or
-                    self.tree.elementInScope("tfoot", variant="table")):
-                self.clearStackToTableBodyContext()
-                self.endTagTableRowGroup(
-                    impliedTagToken(self.tree.openElements[-1].name))
-                return token
-            else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
+    def endTagIgnore(self, token):
+        self.parser.parseError("unexpected-end-tag-in-table-row",
+                               {"name": token["name"]})
+
+    def endTagOther(self, token):
+        return self.parser.phases["inTable"].processEndTag(token)
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        (("td", "th"), startTagTableCell),
+        (("caption", "col", "colgroup", "tbody", "tfoot", "thead",
+          "tr"), startTagTableOther)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("tr", endTagTr),
+        ("table", endTagTable),
+        (("tbody", "tfoot", "thead"), endTagTableRowGroup),
+        (("body", "caption", "col", "colgroup", "html", "td", "th"),
+         endTagIgnore)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class InCellPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-cell
+    __slots__ = tuple()
+
+    # helper
+    def closeCell(self):
+        if self.tree.elementInScope("td", variant="table"):
+            self.endTagTableCell(impliedTagToken("td"))
+        elif self.tree.elementInScope("th", variant="table"):
+            self.endTagTableCell(impliedTagToken("th"))
+
+    # the rest
+    def processEOF(self):
+        self.parser.phases["inBody"].processEOF()
+
+    def processCharacters(self, token):
+        return self.parser.phases["inBody"].processCharacters(token)
+
+    def startTagTableOther(self, token):
+        if (self.tree.elementInScope("td", variant="table") or
+                self.tree.elementInScope("th", variant="table")):
+            self.closeCell()
+            return token
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
+            self.parser.parseError()
 
-        def startTagOther(self, token):
-            return self.parser.phases["inTable"].processStartTag(token)
+    def startTagOther(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
 
-        def endTagTableRowGroup(self, token):
-            if self.tree.elementInScope(token["name"], variant="table"):
-                self.clearStackToTableBodyContext()
-                self.tree.openElements.pop()
-                self.parser.phase = self.parser.phases["inTable"]
-            else:
-                self.parser.parseError("unexpected-end-tag-in-table-body",
+    def endTagTableCell(self, token):
+        if self.tree.elementInScope(token["name"], variant="table"):
+            self.tree.generateImpliedEndTags(token["name"])
+            if self.tree.openElements[-1].name != token["name"]:
+                self.parser.parseError("unexpected-cell-end-tag",
                                        {"name": token["name"]})
-
-        def endTagTable(self, token):
-            if (self.tree.elementInScope("tbody", variant="table") or
-                self.tree.elementInScope("thead", variant="table") or
-                    self.tree.elementInScope("tfoot", variant="table")):
-                self.clearStackToTableBodyContext()
-                self.endTagTableRowGroup(
-                    impliedTagToken(self.tree.openElements[-1].name))
-                return token
+                while True:
+                    node = self.tree.openElements.pop()
+                    if node.name == token["name"]:
+                        break
             else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
-
-        def endTagIgnore(self, token):
-            self.parser.parseError("unexpected-end-tag-in-table-body",
-                                   {"name": token["name"]})
-
-        def endTagOther(self, token):
-            return self.parser.phases["inTable"].processEndTag(token)
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            ("tr", startTagTr),
-            (("td", "th"), startTagTableCell),
-            (("caption", "col", "colgroup", "tbody", "tfoot", "thead"),
-             startTagTableOther)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            (("tbody", "tfoot", "thead"), endTagTableRowGroup),
-            ("table", endTagTable),
-            (("body", "caption", "col", "colgroup", "html", "td", "th",
-              "tr"), endTagIgnore)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InRowPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-row
-        __slots__ = tuple()
-
-        # helper methods (XXX unify this with other table helper methods)
-        def clearStackToTableRowContext(self):
-            while self.tree.openElements[-1].name not in ("tr", "html"):
-                self.parser.parseError("unexpected-implied-end-tag-in-table-row",
-                                       {"name": self.tree.openElements[-1].name})
-                self.tree.openElements.pop()
-
-        def ignoreEndTagTr(self):
-            return not self.tree.elementInScope("tr", variant="table")
-
-        # the rest
-        def processEOF(self):
-            self.parser.phases["inTable"].processEOF()
-
-        def processSpaceCharacters(self, token):
-            return self.parser.phases["inTable"].processSpaceCharacters(token)
-
-        def processCharacters(self, token):
-            return self.parser.phases["inTable"].processCharacters(token)
-
-        def startTagTableCell(self, token):
-            self.clearStackToTableRowContext()
-            self.tree.insertElement(token)
-            self.parser.phase = self.parser.phases["inCell"]
-            self.tree.activeFormattingElements.append(Marker)
-
-        def startTagTableOther(self, token):
-            ignoreEndTag = self.ignoreEndTagTr()
-            self.endTagTr(impliedTagToken("tr"))
-            # XXX how are we sure it's always ignored in the innerHTML case?
-            if not ignoreEndTag:
-                return token
-
-        def startTagOther(self, token):
-            return self.parser.phases["inTable"].processStartTag(token)
-
-        def endTagTr(self, token):
-            if not self.ignoreEndTagTr():
-                self.clearStackToTableRowContext()
                 self.tree.openElements.pop()
-                self.parser.phase = self.parser.phases["inTableBody"]
-            else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
+            self.tree.clearActiveFormattingElements()
+            self.parser.phase = self.parser.phases["inRow"]
+        else:
+            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
 
-        def endTagTable(self, token):
-            ignoreEndTag = self.ignoreEndTagTr()
-            self.endTagTr(impliedTagToken("tr"))
-            # Reprocess the current tag if the tr end tag was not ignored
-            # XXX how are we sure it's always ignored in the innerHTML case?
-            if not ignoreEndTag:
-                return token
+    def endTagIgnore(self, token):
+        self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
 
-        def endTagTableRowGroup(self, token):
-            if self.tree.elementInScope(token["name"], variant="table"):
-                self.endTagTr(impliedTagToken("tr"))
-                return token
-            else:
-                self.parser.parseError()
+    def endTagImply(self, token):
+        if self.tree.elementInScope(token["name"], variant="table"):
+            self.closeCell()
+            return token
+        else:
+            # sometimes innerHTML case
+            self.parser.parseError()
 
-        def endTagIgnore(self, token):
-            self.parser.parseError("unexpected-end-tag-in-table-row",
-                                   {"name": token["name"]})
+    def endTagOther(self, token):
+        return self.parser.phases["inBody"].processEndTag(token)
 
-        def endTagOther(self, token):
-            return self.parser.phases["inTable"].processEndTag(token)
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            (("td", "th"), startTagTableCell),
-            (("caption", "col", "colgroup", "tbody", "tfoot", "thead",
-              "tr"), startTagTableOther)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("tr", endTagTr),
-            ("table", endTagTable),
-            (("tbody", "tfoot", "thead"), endTagTableRowGroup),
-            (("body", "caption", "col", "colgroup", "html", "td", "th"),
-             endTagIgnore)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InCellPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-cell
-        __slots__ = tuple()
-
-        # helper
-        def closeCell(self):
-            if self.tree.elementInScope("td", variant="table"):
-                self.endTagTableCell(impliedTagToken("td"))
-            elif self.tree.elementInScope("th", variant="table"):
-                self.endTagTableCell(impliedTagToken("th"))
-
-        # the rest
-        def processEOF(self):
-            self.parser.phases["inBody"].processEOF()
-
-        def processCharacters(self, token):
-            return self.parser.phases["inBody"].processCharacters(token)
-
-        def startTagTableOther(self, token):
-            if (self.tree.elementInScope("td", variant="table") or
-                    self.tree.elementInScope("th", variant="table")):
-                self.closeCell()
-                return token
-            else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
+          "thead", "tr"), startTagTableOther)
+    ])
+    startTagHandler.default = startTagOther
 
-        def startTagOther(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    endTagHandler = _utils.MethodDispatcher([
+        (("td", "th"), endTagTableCell),
+        (("body", "caption", "col", "colgroup", "html"), endTagIgnore),
+        (("table", "tbody", "tfoot", "thead", "tr"), endTagImply)
+    ])
+    endTagHandler.default = endTagOther
 
-        def endTagTableCell(self, token):
-            if self.tree.elementInScope(token["name"], variant="table"):
-                self.tree.generateImpliedEndTags(token["name"])
-                if self.tree.openElements[-1].name != token["name"]:
-                    self.parser.parseError("unexpected-cell-end-tag",
-                                           {"name": token["name"]})
-                    while True:
-                        node = self.tree.openElements.pop()
-                        if node.name == token["name"]:
-                            break
-                else:
-                    self.tree.openElements.pop()
-                self.tree.clearActiveFormattingElements()
-                self.parser.phase = self.parser.phases["inRow"]
-            else:
-                self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
 
-        def endTagIgnore(self, token):
-            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
+class InSelectPhase(Phase):
+    __slots__ = tuple()
 
-        def endTagImply(self, token):
-            if self.tree.elementInScope(token["name"], variant="table"):
-                self.closeCell()
-                return token
-            else:
-                # sometimes innerHTML case
-                self.parser.parseError()
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-select
+    def processEOF(self):
+        if self.tree.openElements[-1].name != "html":
+            self.parser.parseError("eof-in-select")
+        else:
+            assert self.parser.innerHTML
 
-        def endTagOther(self, token):
-            return self.parser.phases["inBody"].processEndTag(token)
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            (("caption", "col", "colgroup", "tbody", "td", "tfoot", "th",
-              "thead", "tr"), startTagTableOther)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            (("td", "th"), endTagTableCell),
-            (("body", "caption", "col", "colgroup", "html"), endTagIgnore),
-            (("table", "tbody", "tfoot", "thead", "tr"), endTagImply)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InSelectPhase(Phase):
-        __slots__ = tuple()
-
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-select
-        def processEOF(self):
-            if self.tree.openElements[-1].name != "html":
-                self.parser.parseError("eof-in-select")
-            else:
-                assert self.parser.innerHTML
+    def processCharacters(self, token):
+        if token["data"] == "\u0000":
+            return
+        self.tree.insertText(token["data"])
 
-        def processCharacters(self, token):
-            if token["data"] == "\u0000":
-                return
-            self.tree.insertText(token["data"])
+    def startTagOption(self, token):
+        # We need to imply </option> if <option> is the current node.
+        if self.tree.openElements[-1].name == "option":
+            self.tree.openElements.pop()
+        self.tree.insertElement(token)
 
-        def startTagOption(self, token):
-            # We need to imply </option> if <option> is the current node.
-            if self.tree.openElements[-1].name == "option":
-                self.tree.openElements.pop()
-            self.tree.insertElement(token)
+    def startTagOptgroup(self, token):
+        if self.tree.openElements[-1].name == "option":
+            self.tree.openElements.pop()
+        if self.tree.openElements[-1].name == "optgroup":
+            self.tree.openElements.pop()
+        self.tree.insertElement(token)
 
-        def startTagOptgroup(self, token):
-            if self.tree.openElements[-1].name == "option":
-                self.tree.openElements.pop()
-            if self.tree.openElements[-1].name == "optgroup":
-                self.tree.openElements.pop()
-            self.tree.insertElement(token)
+    def startTagSelect(self, token):
+        self.parser.parseError("unexpected-select-in-select")
+        self.endTagSelect(impliedTagToken("select"))
 
-        def startTagSelect(self, token):
-            self.parser.parseError("unexpected-select-in-select")
+    def startTagInput(self, token):
+        self.parser.parseError("unexpected-input-in-select")
+        if self.tree.elementInScope("select", variant="select"):
             self.endTagSelect(impliedTagToken("select"))
+            return token
+        else:
+            assert self.parser.innerHTML
 
-        def startTagInput(self, token):
-            self.parser.parseError("unexpected-input-in-select")
-            if self.tree.elementInScope("select", variant="select"):
-                self.endTagSelect(impliedTagToken("select"))
-                return token
-            else:
-                assert self.parser.innerHTML
-
-        def startTagScript(self, token):
-            return self.parser.phases["inHead"].processStartTag(token)
+    def startTagScript(self, token):
+        return self.parser.phases["inHead"].processStartTag(token)
 
-        def startTagOther(self, token):
-            self.parser.parseError("unexpected-start-tag-in-select",
-                                   {"name": token["name"]})
+    def startTagOther(self, token):
+        self.parser.parseError("unexpected-start-tag-in-select",
+                               {"name": token["name"]})
 
-        def endTagOption(self, token):
-            if self.tree.openElements[-1].name == "option":
-                self.tree.openElements.pop()
-            else:
-                self.parser.parseError("unexpected-end-tag-in-select",
-                                       {"name": "option"})
+    def endTagOption(self, token):
+        if self.tree.openElements[-1].name == "option":
+            self.tree.openElements.pop()
+        else:
+            self.parser.parseError("unexpected-end-tag-in-select",
+                                   {"name": "option"})
 
-        def endTagOptgroup(self, token):
-            # </optgroup> implicitly closes <option>
-            if (self.tree.openElements[-1].name == "option" and
-                    self.tree.openElements[-2].name == "optgroup"):
-                self.tree.openElements.pop()
-            # It also closes </optgroup>
-            if self.tree.openElements[-1].name == "optgroup":
-                self.tree.openElements.pop()
-            # But nothing else
-            else:
-                self.parser.parseError("unexpected-end-tag-in-select",
-                                       {"name": "optgroup"})
+    def endTagOptgroup(self, token):
+        # </optgroup> implicitly closes <option>
+        if (self.tree.openElements[-1].name == "option" and
+                self.tree.openElements[-2].name == "optgroup"):
+            self.tree.openElements.pop()
+        # It also closes </optgroup>
+        if self.tree.openElements[-1].name == "optgroup":
+            self.tree.openElements.pop()
+        # But nothing else
+        else:
+            self.parser.parseError("unexpected-end-tag-in-select",
+                                   {"name": "optgroup"})
 
-        def endTagSelect(self, token):
-            if self.tree.elementInScope("select", variant="select"):
+    def endTagSelect(self, token):
+        if self.tree.elementInScope("select", variant="select"):
+            node = self.tree.openElements.pop()
+            while node.name != "select":
                 node = self.tree.openElements.pop()
-                while node.name != "select":
-                    node = self.tree.openElements.pop()
-                self.parser.resetInsertionMode()
-            else:
-                # innerHTML case
-                assert self.parser.innerHTML
-                self.parser.parseError()
-
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag-in-select",
-                                   {"name": token["name"]})
+            self.parser.resetInsertionMode()
+        else:
+            # innerHTML case
+            assert self.parser.innerHTML
+            self.parser.parseError()
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            ("option", startTagOption),
-            ("optgroup", startTagOptgroup),
-            ("select", startTagSelect),
-            (("input", "keygen", "textarea"), startTagInput),
-            ("script", startTagScript)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("option", endTagOption),
-            ("optgroup", endTagOptgroup),
-            ("select", endTagSelect)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InSelectInTablePhase(Phase):
-        __slots__ = tuple()
-
-        def processEOF(self):
-            self.parser.phases["inSelect"].processEOF()
-
-        def processCharacters(self, token):
-            return self.parser.phases["inSelect"].processCharacters(token)
-
-        def startTagTable(self, token):
-            self.parser.parseError("unexpected-table-element-start-tag-in-select-in-table", {"name": token["name"]})
-            self.endTagOther(impliedTagToken("select"))
-            return token
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag-in-select",
+                               {"name": token["name"]})
 
-        def startTagOther(self, token):
-            return self.parser.phases["inSelect"].processStartTag(token)
-
-        def endTagTable(self, token):
-            self.parser.parseError("unexpected-table-element-end-tag-in-select-in-table", {"name": token["name"]})
-            if self.tree.elementInScope(token["name"], variant="table"):
-                self.endTagOther(impliedTagToken("select"))
-                return token
-
-        def endTagOther(self, token):
-            return self.parser.phases["inSelect"].processEndTag(token)
-
-        startTagHandler = _utils.MethodDispatcher([
-            (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
-             startTagTable)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
-             endTagTable)
-        ])
-        endTagHandler.default = endTagOther
-
-    class InForeignContentPhase(Phase):
-        __slots__ = tuple()
-
-        breakoutElements = frozenset(["b", "big", "blockquote", "body", "br",
-                                      "center", "code", "dd", "div", "dl", "dt",
-                                      "em", "embed", "h1", "h2", "h3",
-                                      "h4", "h5", "h6", "head", "hr", "i", "img",
-                                      "li", "listing", "menu", "meta", "nobr",
-                                      "ol", "p", "pre", "ruby", "s", "small",
-                                      "span", "strong", "strike", "sub", "sup",
-                                      "table", "tt", "u", "ul", "var"])
-
-        def adjustSVGTagNames(self, token):
-            replacements = {"altglyph": "altGlyph",
-                            "altglyphdef": "altGlyphDef",
-                            "altglyphitem": "altGlyphItem",
-                            "animatecolor": "animateColor",
-                            "animatemotion": "animateMotion",
-                            "animatetransform": "animateTransform",
-                            "clippath": "clipPath",
-                            "feblend": "feBlend",
-                            "fecolormatrix": "feColorMatrix",
-                            "fecomponenttransfer": "feComponentTransfer",
-                            "fecomposite": "feComposite",
-                            "feconvolvematrix": "feConvolveMatrix",
-                            "fediffuselighting": "feDiffuseLighting",
-                            "fedisplacementmap": "feDisplacementMap",
-                            "fedistantlight": "feDistantLight",
-                            "feflood": "feFlood",
-                            "fefunca": "feFuncA",
-                            "fefuncb": "feFuncB",
-                            "fefuncg": "feFuncG",
-                            "fefuncr": "feFuncR",
-                            "fegaussianblur": "feGaussianBlur",
-                            "feimage": "feImage",
-                            "femerge": "feMerge",
-                            "femergenode": "feMergeNode",
-                            "femorphology": "feMorphology",
-                            "feoffset": "feOffset",
-                            "fepointlight": "fePointLight",
-                            "fespecularlighting": "feSpecularLighting",
-                            "fespotlight": "feSpotLight",
-                            "fetile": "feTile",
-                            "feturbulence": "feTurbulence",
-                            "foreignobject": "foreignObject",
-                            "glyphref": "glyphRef",
-                            "lineargradient": "linearGradient",
-                            "radialgradient": "radialGradient",
-                            "textpath": "textPath"}
-
-            if token["name"] in replacements:
-                token["name"] = replacements[token["name"]]
-
-        def processCharacters(self, token):
-            if token["data"] == "\u0000":
-                token["data"] = "\uFFFD"
-            elif (self.parser.framesetOK and
-                  any(char not in spaceCharacters for char in token["data"])):
-                self.parser.framesetOK = False
-            Phase.processCharacters(self, token)
-
-        def processStartTag(self, token):
-            currentNode = self.tree.openElements[-1]
-            if (token["name"] in self.breakoutElements or
-                (token["name"] == "font" and
-                 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 !=
-                       self.tree.defaultNamespace and
-                       not self.parser.isHTMLIntegrationPoint(self.tree.openElements[-1]) and
-                       not self.parser.isMathMLTextIntegrationPoint(self.tree.openElements[-1])):
-                    self.tree.openElements.pop()
-                return token
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        ("option", startTagOption),
+        ("optgroup", startTagOptgroup),
+        ("select", startTagSelect),
+        (("input", "keygen", "textarea"), startTagInput),
+        ("script", startTagScript)
+    ])
+    startTagHandler.default = startTagOther
 
-            else:
-                if currentNode.namespace == namespaces["mathml"]:
-                    self.parser.adjustMathMLAttributes(token)
-                elif currentNode.namespace == namespaces["svg"]:
-                    self.adjustSVGTagNames(token)
-                    self.parser.adjustSVGAttributes(token)
-                self.parser.adjustForeignAttributes(token)
-                token["namespace"] = currentNode.namespace
-                self.tree.insertElement(token)
-                if token["selfClosing"]:
-                    self.tree.openElements.pop()
-                    token["selfClosingAcknowledged"] = True
-
-        def processEndTag(self, token):
-            nodeIndex = len(self.tree.openElements) - 1
-            node = self.tree.openElements[-1]
-            if node.name.translate(asciiUpper2Lower) != token["name"]:
-                self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
-
-            while True:
-                if node.name.translate(asciiUpper2Lower) == token["name"]:
-                    # XXX this isn't in the spec but it seems necessary
-                    if self.parser.phase == self.parser.phases["inTableText"]:
-                        self.parser.phase.flushCharacters()
-                        self.parser.phase = self.parser.phase.originalPhase
-                    while self.tree.openElements.pop() != node:
-                        assert self.tree.openElements
-                    new_token = None
-                    break
-                nodeIndex -= 1
+    endTagHandler = _utils.MethodDispatcher([
+        ("option", endTagOption),
+        ("optgroup", endTagOptgroup),
+        ("select", endTagSelect)
+    ])
+    endTagHandler.default = endTagOther
 
-                node = self.tree.openElements[nodeIndex]
-                if node.namespace != self.tree.defaultNamespace:
-                    continue
-                else:
-                    new_token = self.parser.phase.processEndTag(token)
-                    break
-            return new_token
 
-    class AfterBodyPhase(Phase):
-        __slots__ = tuple()
+class InSelectInTablePhase(Phase):
+    __slots__ = tuple()
 
-        def processEOF(self):
-            # Stop parsing
-            pass
+    def processEOF(self):
+        self.parser.phases["inSelect"].processEOF()
 
-        def processComment(self, token):
-            # This is needed because data is to be appended to the <html> element
-            # here and not to whatever is currently open.
-            self.tree.insertComment(token, self.tree.openElements[0])
+    def processCharacters(self, token):
+        return self.parser.phases["inSelect"].processCharacters(token)
 
-        def processCharacters(self, token):
-            self.parser.parseError("unexpected-char-after-body")
-            self.parser.phase = self.parser.phases["inBody"]
-            return token
+    def startTagTable(self, token):
+        self.parser.parseError("unexpected-table-element-start-tag-in-select-in-table", {"name": token["name"]})
+        self.endTagOther(impliedTagToken("select"))
+        return token
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def startTagOther(self, token):
+        return self.parser.phases["inSelect"].processStartTag(token)
 
-        def startTagOther(self, token):
-            self.parser.parseError("unexpected-start-tag-after-body",
-                                   {"name": token["name"]})
-            self.parser.phase = self.parser.phases["inBody"]
+    def endTagTable(self, token):
+        self.parser.parseError("unexpected-table-element-end-tag-in-select-in-table", {"name": token["name"]})
+        if self.tree.elementInScope(token["name"], variant="table"):
+            self.endTagOther(impliedTagToken("select"))
             return token
 
-        def endTagHtml(self, name):
-            if self.parser.innerHTML:
-                self.parser.parseError("unexpected-end-tag-after-body-innerhtml")
-            else:
-                self.parser.phase = self.parser.phases["afterAfterBody"]
-
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag-after-body",
+    def endTagOther(self, token):
+        return self.parser.phases["inSelect"].processEndTag(token)
+
+    startTagHandler = _utils.MethodDispatcher([
+        (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
+         startTagTable)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        (("caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"),
+         endTagTable)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class InForeignContentPhase(Phase):
+    __slots__ = tuple()
+
+    breakoutElements = frozenset(["b", "big", "blockquote", "body", "br",
+                                  "center", "code", "dd", "div", "dl", "dt",
+                                  "em", "embed", "h1", "h2", "h3",
+                                  "h4", "h5", "h6", "head", "hr", "i", "img",
+                                  "li", "listing", "menu", "meta", "nobr",
+                                  "ol", "p", "pre", "ruby", "s", "small",
+                                  "span", "strong", "strike", "sub", "sup",
+                                  "table", "tt", "u", "ul", "var"])
+
+    def adjustSVGTagNames(self, token):
+        replacements = {"altglyph": "altGlyph",
+                        "altglyphdef": "altGlyphDef",
+                        "altglyphitem": "altGlyphItem",
+                        "animatecolor": "animateColor",
+                        "animatemotion": "animateMotion",
+                        "animatetransform": "animateTransform",
+                        "clippath": "clipPath",
+                        "feblend": "feBlend",
+                        "fecolormatrix": "feColorMatrix",
+                        "fecomponenttransfer": "feComponentTransfer",
+                        "fecomposite": "feComposite",
+                        "feconvolvematrix": "feConvolveMatrix",
+                        "fediffuselighting": "feDiffuseLighting",
+                        "fedisplacementmap": "feDisplacementMap",
+                        "fedistantlight": "feDistantLight",
+                        "feflood": "feFlood",
+                        "fefunca": "feFuncA",
+                        "fefuncb": "feFuncB",
+                        "fefuncg": "feFuncG",
+                        "fefuncr": "feFuncR",
+                        "fegaussianblur": "feGaussianBlur",
+                        "feimage": "feImage",
+                        "femerge": "feMerge",
+                        "femergenode": "feMergeNode",
+                        "femorphology": "feMorphology",
+                        "feoffset": "feOffset",
+                        "fepointlight": "fePointLight",
+                        "fespecularlighting": "feSpecularLighting",
+                        "fespotlight": "feSpotLight",
+                        "fetile": "feTile",
+                        "feturbulence": "feTurbulence",
+                        "foreignobject": "foreignObject",
+                        "glyphref": "glyphRef",
+                        "lineargradient": "linearGradient",
+                        "radialgradient": "radialGradient",
+                        "textpath": "textPath"}
+
+        if token["name"] in replacements:
+            token["name"] = replacements[token["name"]]
+
+    def processCharacters(self, token):
+        if token["data"] == "\u0000":
+            token["data"] = "\uFFFD"
+        elif (self.parser.framesetOK and
+              any(char not in spaceCharacters for char in token["data"])):
+            self.parser.framesetOK = False
+        Phase.processCharacters(self, token)
+
+    def processStartTag(self, token):
+        currentNode = self.tree.openElements[-1]
+        if (token["name"] in self.breakoutElements or
+            (token["name"] == "font" and
+             set(token["data"].keys()) & {"color", "face", "size"})):
+            self.parser.parseError("unexpected-html-element-in-foreign-content",
                                    {"name": token["name"]})
-            self.parser.phase = self.parser.phases["inBody"]
+            while (self.tree.openElements[-1].namespace !=
+                   self.tree.defaultNamespace and
+                   not self.parser.isHTMLIntegrationPoint(self.tree.openElements[-1]) and
+                   not self.parser.isMathMLTextIntegrationPoint(self.tree.openElements[-1])):
+                self.tree.openElements.pop()
             return token
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml)
-        ])
-        startTagHandler.default = startTagOther
+        else:
+            if currentNode.namespace == namespaces["mathml"]:
+                self.parser.adjustMathMLAttributes(token)
+            elif currentNode.namespace == namespaces["svg"]:
+                self.adjustSVGTagNames(token)
+                self.parser.adjustSVGAttributes(token)
+            self.parser.adjustForeignAttributes(token)
+            token["namespace"] = currentNode.namespace
+            self.tree.insertElement(token)
+            if token["selfClosing"]:
+                self.tree.openElements.pop()
+                token["selfClosingAcknowledged"] = True
 
-        endTagHandler = _utils.MethodDispatcher([("html", endTagHtml)])
-        endTagHandler.default = endTagOther
+    def processEndTag(self, token):
+        nodeIndex = len(self.tree.openElements) - 1
+        node = self.tree.openElements[-1]
+        if node.name.translate(asciiUpper2Lower) != token["name"]:
+            self.parser.parseError("unexpected-end-tag", {"name": token["name"]})
 
-    class InFramesetPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset
-        __slots__ = tuple()
+        while True:
+            if node.name.translate(asciiUpper2Lower) == token["name"]:
+                # XXX this isn't in the spec but it seems necessary
+                if self.parser.phase == self.parser.phases["inTableText"]:
+                    self.parser.phase.flushCharacters()
+                    self.parser.phase = self.parser.phase.originalPhase
+                while self.tree.openElements.pop() != node:
+                    assert self.tree.openElements
+                new_token = None
+                break
+            nodeIndex -= 1
 
-        def processEOF(self):
-            if self.tree.openElements[-1].name != "html":
-                self.parser.parseError("eof-in-frameset")
+            node = self.tree.openElements[nodeIndex]
+            if node.namespace != self.tree.defaultNamespace:
+                continue
             else:
-                assert self.parser.innerHTML
+                new_token = self.parser.phase.processEndTag(token)
+                break
+        return new_token
 
-        def processCharacters(self, token):
-            self.parser.parseError("unexpected-char-in-frameset")
 
-        def startTagFrameset(self, token):
-            self.tree.insertElement(token)
+class AfterBodyPhase(Phase):
+    __slots__ = tuple()
 
-        def startTagFrame(self, token):
-            self.tree.insertElement(token)
-            self.tree.openElements.pop()
+    def processEOF(self):
+        # Stop parsing
+        pass
 
-        def startTagNoframes(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def processComment(self, token):
+        # This is needed because data is to be appended to the <html> element
+        # here and not to whatever is currently open.
+        self.tree.insertComment(token, self.tree.openElements[0])
 
-        def startTagOther(self, token):
-            self.parser.parseError("unexpected-start-tag-in-frameset",
-                                   {"name": token["name"]})
+    def processCharacters(self, token):
+        self.parser.parseError("unexpected-char-after-body")
+        self.parser.phase = self.parser.phases["inBody"]
+        return token
 
-        def endTagFrameset(self, token):
-            if self.tree.openElements[-1].name == "html":
-                # innerHTML case
-                self.parser.parseError("unexpected-frameset-in-frameset-innerhtml")
-            else:
-                self.tree.openElements.pop()
-            if (not self.parser.innerHTML and
-                    self.tree.openElements[-1].name != "frameset"):
-                # If we're not in innerHTML mode and the current node is not a
-                # "frameset" element (anymore) then switch.
-                self.parser.phase = self.parser.phases["afterFrameset"]
-
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag-in-frameset",
-                                   {"name": token["name"]})
-
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            ("frameset", startTagFrameset),
-            ("frame", startTagFrame),
-            ("noframes", startTagNoframes)
-        ])
-        startTagHandler.default = startTagOther
-
-        endTagHandler = _utils.MethodDispatcher([
-            ("frameset", endTagFrameset)
-        ])
-        endTagHandler.default = endTagOther
-
-    class AfterFramesetPhase(Phase):
-        # http://www.whatwg.org/specs/web-apps/current-work/#after3
-        __slots__ = tuple()
-
-        def processEOF(self):
-            # Stop parsing
-            pass
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
 
-        def processCharacters(self, token):
-            self.parser.parseError("unexpected-char-after-frameset")
+    def startTagOther(self, token):
+        self.parser.parseError("unexpected-start-tag-after-body",
+                               {"name": token["name"]})
+        self.parser.phase = self.parser.phases["inBody"]
+        return token
 
-        def startTagNoframes(self, token):
-            return self.parser.phases["inHead"].processStartTag(token)
+    def endTagHtml(self, name):
+        if self.parser.innerHTML:
+            self.parser.parseError("unexpected-end-tag-after-body-innerhtml")
+        else:
+            self.parser.phase = self.parser.phases["afterAfterBody"]
 
-        def startTagOther(self, token):
-            self.parser.parseError("unexpected-start-tag-after-frameset",
-                                   {"name": token["name"]})
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag-after-body",
+                               {"name": token["name"]})
+        self.parser.phase = self.parser.phases["inBody"]
+        return token
 
-        def endTagHtml(self, token):
-            self.parser.phase = self.parser.phases["afterAfterFrameset"]
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml)
+    ])
+    startTagHandler.default = startTagOther
 
-        def endTagOther(self, token):
-            self.parser.parseError("unexpected-end-tag-after-frameset",
-                                   {"name": token["name"]})
+    endTagHandler = _utils.MethodDispatcher([("html", endTagHtml)])
+    endTagHandler.default = endTagOther
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", Phase.startTagHtml),
-            ("noframes", startTagNoframes)
-        ])
-        startTagHandler.default = startTagOther
 
-        endTagHandler = _utils.MethodDispatcher([
-            ("html", endTagHtml)
-        ])
-        endTagHandler.default = endTagOther
+class InFramesetPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset
+    __slots__ = tuple()
 
-    class AfterAfterBodyPhase(Phase):
-        __slots__ = tuple()
+    def processEOF(self):
+        if self.tree.openElements[-1].name != "html":
+            self.parser.parseError("eof-in-frameset")
+        else:
+            assert self.parser.innerHTML
 
-        def processEOF(self):
-            pass
+    def processCharacters(self, token):
+        self.parser.parseError("unexpected-char-in-frameset")
 
-        def processComment(self, token):
-            self.tree.insertComment(token, self.tree.document)
+    def startTagFrameset(self, token):
+        self.tree.insertElement(token)
 
-        def processSpaceCharacters(self, token):
-            return self.parser.phases["inBody"].processSpaceCharacters(token)
+    def startTagFrame(self, token):
+        self.tree.insertElement(token)
+        self.tree.openElements.pop()
 
-        def processCharacters(self, token):
-            self.parser.parseError("expected-eof-but-got-char")
-            self.parser.phase = self.parser.phases["inBody"]
-            return token
+    def startTagNoframes(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def startTagOther(self, token):
+        self.parser.parseError("unexpected-start-tag-in-frameset",
+                               {"name": token["name"]})
 
-        def startTagOther(self, token):
-            self.parser.parseError("expected-eof-but-got-start-tag",
-                                   {"name": token["name"]})
-            self.parser.phase = self.parser.phases["inBody"]
-            return token
+    def endTagFrameset(self, token):
+        if self.tree.openElements[-1].name == "html":
+            # innerHTML case
+            self.parser.parseError("unexpected-frameset-in-frameset-innerhtml")
+        else:
+            self.tree.openElements.pop()
+        if (not self.parser.innerHTML and
+                self.tree.openElements[-1].name != "frameset"):
+            # If we're not in innerHTML mode and the current node is not a
+            # "frameset" element (anymore) then switch.
+            self.parser.phase = self.parser.phases["afterFrameset"]
 
-        def processEndTag(self, token):
-            self.parser.parseError("expected-eof-but-got-end-tag",
-                                   {"name": token["name"]})
-            self.parser.phase = self.parser.phases["inBody"]
-            return token
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag-in-frameset",
+                               {"name": token["name"]})
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml)
-        ])
-        startTagHandler.default = startTagOther
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        ("frameset", startTagFrameset),
+        ("frame", startTagFrame),
+        ("noframes", startTagNoframes)
+    ])
+    startTagHandler.default = startTagOther
 
-    class AfterAfterFramesetPhase(Phase):
-        __slots__ = tuple()
+    endTagHandler = _utils.MethodDispatcher([
+        ("frameset", endTagFrameset)
+    ])
+    endTagHandler.default = endTagOther
 
-        def processEOF(self):
-            pass
 
-        def processComment(self, token):
-            self.tree.insertComment(token, self.tree.document)
+class AfterFramesetPhase(Phase):
+    # http://www.whatwg.org/specs/web-apps/current-work/#after3
+    __slots__ = tuple()
 
-        def processSpaceCharacters(self, token):
-            return self.parser.phases["inBody"].processSpaceCharacters(token)
+    def processEOF(self):
+        # Stop parsing
+        pass
 
-        def processCharacters(self, token):
-            self.parser.parseError("expected-eof-but-got-char")
+    def processCharacters(self, token):
+        self.parser.parseError("unexpected-char-after-frameset")
 
-        def startTagHtml(self, token):
-            return self.parser.phases["inBody"].processStartTag(token)
+    def startTagNoframes(self, token):
+        return self.parser.phases["inHead"].processStartTag(token)
 
-        def startTagNoFrames(self, token):
-            return self.parser.phases["inHead"].processStartTag(token)
+    def startTagOther(self, token):
+        self.parser.parseError("unexpected-start-tag-after-frameset",
+                               {"name": token["name"]})
 
-        def startTagOther(self, token):
-            self.parser.parseError("expected-eof-but-got-start-tag",
-                                   {"name": token["name"]})
+    def endTagHtml(self, token):
+        self.parser.phase = self.parser.phases["afterAfterFrameset"]
 
-        def processEndTag(self, token):
-            self.parser.parseError("expected-eof-but-got-end-tag",
-                                   {"name": token["name"]})
+    def endTagOther(self, token):
+        self.parser.parseError("unexpected-end-tag-after-frameset",
+                               {"name": token["name"]})
 
-        startTagHandler = _utils.MethodDispatcher([
-            ("html", startTagHtml),
-            ("noframes", startTagNoFrames)
-        ])
-        startTagHandler.default = startTagOther
-
-    # pylint:enable=unused-argument
-
-    return {
-        "initial": InitialPhase,
-        "beforeHtml": BeforeHtmlPhase,
-        "beforeHead": BeforeHeadPhase,
-        "inHead": InHeadPhase,
-        "inHeadNoscript": InHeadNoscriptPhase,
-        "afterHead": AfterHeadPhase,
-        "inBody": InBodyPhase,
-        "text": TextPhase,
-        "inTable": InTablePhase,
-        "inTableText": InTableTextPhase,
-        "inCaption": InCaptionPhase,
-        "inColumnGroup": InColumnGroupPhase,
-        "inTableBody": InTableBodyPhase,
-        "inRow": InRowPhase,
-        "inCell": InCellPhase,
-        "inSelect": InSelectPhase,
-        "inSelectInTable": InSelectInTablePhase,
-        "inForeignContent": InForeignContentPhase,
-        "afterBody": AfterBodyPhase,
-        "inFrameset": InFramesetPhase,
-        "afterFrameset": AfterFramesetPhase,
-        "afterAfterBody": AfterAfterBodyPhase,
-        "afterAfterFrameset": AfterAfterFramesetPhase,
-        # XXX after after frameset
-    }
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", Phase.startTagHtml),
+        ("noframes", startTagNoframes)
+    ])
+    startTagHandler.default = startTagOther
+
+    endTagHandler = _utils.MethodDispatcher([
+        ("html", endTagHtml)
+    ])
+    endTagHandler.default = endTagOther
+
+
+class AfterAfterBodyPhase(Phase):
+    __slots__ = tuple()
+
+    def processEOF(self):
+        pass
+
+    def processComment(self, token):
+        self.tree.insertComment(token, self.tree.document)
+
+    def processSpaceCharacters(self, token):
+        return self.parser.phases["inBody"].processSpaceCharacters(token)
+
+    def processCharacters(self, token):
+        self.parser.parseError("expected-eof-but-got-char")
+        self.parser.phase = self.parser.phases["inBody"]
+        return token
+
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
+
+    def startTagOther(self, token):
+        self.parser.parseError("expected-eof-but-got-start-tag",
+                               {"name": token["name"]})
+        self.parser.phase = self.parser.phases["inBody"]
+        return token
+
+    def processEndTag(self, token):
+        self.parser.parseError("expected-eof-but-got-end-tag",
+                               {"name": token["name"]})
+        self.parser.phase = self.parser.phases["inBody"]
+        return token
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml)
+    ])
+    startTagHandler.default = startTagOther
+
+
+class AfterAfterFramesetPhase(Phase):
+    __slots__ = tuple()
+
+    def processEOF(self):
+        pass
+
+    def processComment(self, token):
+        self.tree.insertComment(token, self.tree.document)
+
+    def processSpaceCharacters(self, token):
+        return self.parser.phases["inBody"].processSpaceCharacters(token)
+
+    def processCharacters(self, token):
+        self.parser.parseError("expected-eof-but-got-char")
+
+    def startTagHtml(self, token):
+        return self.parser.phases["inBody"].processStartTag(token)
+
+    def startTagNoFrames(self, token):
+        return self.parser.phases["inHead"].processStartTag(token)
+
+    def startTagOther(self, token):
+        self.parser.parseError("expected-eof-but-got-start-tag",
+                               {"name": token["name"]})
+
+    def processEndTag(self, token):
+        self.parser.parseError("expected-eof-but-got-end-tag",
+                               {"name": token["name"]})
+
+    startTagHandler = _utils.MethodDispatcher([
+        ("html", startTagHtml),
+        ("noframes", startTagNoFrames)
+    ])
+    startTagHandler.default = startTagOther
+
+# pylint:enable=unused-argument
+
+
+_phases = {
+    "initial": InitialPhase,
+    "beforeHtml": BeforeHtmlPhase,
+    "beforeHead": BeforeHeadPhase,
+    "inHead": InHeadPhase,
+    "inHeadNoscript": InHeadNoscriptPhase,
+    "afterHead": AfterHeadPhase,
+    "inBody": InBodyPhase,
+    "text": TextPhase,
+    "inTable": InTablePhase,
+    "inTableText": InTableTextPhase,
+    "inCaption": InCaptionPhase,
+    "inColumnGroup": InColumnGroupPhase,
+    "inTableBody": InTableBodyPhase,
+    "inRow": InRowPhase,
+    "inCell": InCellPhase,
+    "inSelect": InSelectPhase,
+    "inSelectInTable": InSelectInTablePhase,
+    "inForeignContent": InForeignContentPhase,
+    "afterBody": AfterBodyPhase,
+    "inFrameset": InFramesetPhase,
+    "afterFrameset": AfterFramesetPhase,
+    "afterAfterBody": AfterAfterBodyPhase,
+    "afterAfterFrameset": AfterAfterFramesetPhase,
+    # XXX after after frameset
+}
 
 
 def adjust_attributes(token, replacements):
diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py
index 879d2447..6b464bea 100644
--- a/html5lib/tests/test_parser2.py
+++ b/html5lib/tests/test_parser2.py
@@ -68,7 +68,6 @@ def test_debug_log():
                 ('dataState', 'InBodyPhase', 'InBodyPhase', 'processStartTag', {'name': 'p', 'type': 'StartTag'}),
                 ('dataState', 'InBodyPhase', 'InBodyPhase', 'processCharacters', {'type': 'Characters'}),
                 ('dataState', 'InBodyPhase', 'InBodyPhase', 'processStartTag', {'name': 'script', 'type': 'StartTag'}),
-                ('dataState', 'InBodyPhase', 'InHeadPhase', 'processStartTag', {'name': 'script', 'type': 'StartTag'}),
                 ('scriptDataState', 'TextPhase', 'TextPhase', 'processCharacters', {'type': 'Characters'}),
                 ('dataState', 'TextPhase', 'TextPhase', 'processEndTag', {'name': 'script', 'type': 'EndTag'}),
                 ('dataState', 'InBodyPhase', 'InBodyPhase', 'processCharacters', {'type': 'Characters'}),
