Skip to content

Commit 8b4d7c4

Browse files
committed
Drop the content model requirements from lint
1 parent fbbea1f commit 8b4d7c4

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

html5lib/filters/lint.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from six import text_type
44

55
from . import _base
6-
from ..constants import cdataElements, rcdataElements, voidElements
6+
from ..constants import voidElements
77

88
from ..constants import spaceCharacters
99
spaceCharacters = "".join(spaceCharacters)
@@ -16,13 +16,10 @@ class LintError(Exception):
1616
class Filter(_base.Filter):
1717
def __iter__(self):
1818
open_elements = []
19-
contentModelFlag = "PCDATA"
2019
for token in _base.Filter.__iter__(self):
2120
type = token["type"]
2221
if type in ("StartTag", "EmptyTag"):
2322
name = token["name"]
24-
if contentModelFlag != "PCDATA":
25-
raise LintError("StartTag not in PCDATA content model flag: %(tag)s" % {"tag": name})
2623
if not isinstance(name, text_type):
2724
raise LintError("Tag name is not a string: %(tag)r" % {"tag": name})
2825
if not name:
@@ -44,12 +41,6 @@ def __iter__(self):
4441
raise LintError("Empty attribute localname")
4542
if not isinstance(value, text_type):
4643
raise LintError("Attribute value is not a string: %(value)r" % {"value": value})
47-
if name in cdataElements:
48-
contentModelFlag = "CDATA"
49-
elif name in rcdataElements:
50-
contentModelFlag = "RCDATA"
51-
elif name == "plaintext":
52-
contentModelFlag = "PLAINTEXT"
5344

5445
elif type == "EndTag":
5546
name = token["name"]
@@ -62,11 +53,9 @@ def __iter__(self):
6253
start_name = open_elements.pop()
6354
if start_name != name:
6455
raise LintError("EndTag (%(end)s) does not match StartTag (%(start)s)" % {"end": name, "start": start_name})
65-
contentModelFlag = "PCDATA"
6656

6757
elif type == "Comment":
68-
if contentModelFlag != "PCDATA":
69-
raise LintError("Comment not in PCDATA content model flag")
58+
pass
7059

7160
elif type in ("Characters", "SpaceCharacters"):
7261
data = token["data"]
@@ -81,8 +70,6 @@ def __iter__(self):
8170

8271
elif type == "Doctype":
8372
name = token["name"]
84-
if contentModelFlag != "PCDATA":
85-
raise LintError("Doctype not in PCDATA content model flag: %(name)s" % {"name": name})
8673
if not isinstance(name, text_type):
8774
raise LintError("Tag name is not a string: %(tag)r" % {"tag": name})
8875
# XXX: what to do with token["data"] ?

0 commit comments

Comments
 (0)