Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ddce87

Browse files
committed
Lint serializer test input; fix broken examples
1 parentda12b01 commit6ddce87

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

‎html5lib/filters/lint.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111

1212
classFilter(_base.Filter):
13+
def__init__(self,source,require_matching_tags=True):
14+
super(Filter,self).__init__(source)
15+
self.require_matching_tags=require_matching_tags
16+
1317
def__iter__(self):
1418
open_elements= []
1519
fortokenin_base.Filter.__iter__(self):
@@ -26,7 +30,7 @@ def __iter__(self):
2630
asserttype=="EmptyTag"
2731
else:
2832
asserttype=="StartTag"
29-
iftype=="StartTag":
33+
iftype=="StartTag"andself.require_matching_tags:
3034
open_elements.append((namespace,name))
3135
for (namespace,name),valueintoken["data"].items():
3236
assertnamespaceisNoneorisinstance(namespace,text_type)
@@ -44,7 +48,7 @@ def __iter__(self):
4448
assertname!=""
4549
if (notnamespaceornamespace==namespaces["html"])andnameinvoidElements:
4650
assertFalse,"Void element reported as EndTag token: %(tag)s"% {"tag":name}
47-
else:
51+
elifself.require_matching_tags:
4852
start=open_elements.pop()
4953
assertstart== (namespace,name)
5054

‎html5lib/tests/serializer-testdata/core.test

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,20 +293,6 @@
293293
],
294294
"description": "void element (as EmptyTag token)"
295295
},
296-
{
297-
"expected": [
298-
"<img>"
299-
],
300-
"input": [
301-
[
302-
"StartTag",
303-
"http://www.w3.org/1999/xhtml",
304-
"img",
305-
{}
306-
]
307-
],
308-
"description": "void element (as StartTag token)"
309-
},
310296
{
311297
"expected": [
312298
"<!DOCTYPE foo>"

‎html5lib/tests/serializer-testdata/optionaltags.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@
347347
},
348348
{
349349
"expected": [
350-
"<foo>"
350+
"<meta>"
351351
],
352352
"input": [
353353
[
@@ -358,7 +358,7 @@
358358
],
359359
[
360360
"EmptyTag",
361-
"foo",
361+
"meta",
362362
{}
363363
]
364364
],
@@ -2094,7 +2094,7 @@
20942094
{}
20952095
],
20962096
[
2097-
"StartTag",
2097+
"EmptyTag",
20982098
"http://www.w3.org/1999/xhtml",
20992099
"col",
21002100
{}

‎html5lib/tests/test_serializer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
importhtml5lib
1515
fromhtml5libimportconstants
16+
fromhtml5lib.filters.lintimportFilterasLint
1617
fromhtml5lib.serializerimportHTMLSerializer,serialize
1718
fromhtml5lib.treewalkers._baseimportTreeWalker
1819

@@ -83,7 +84,7 @@ def _convertAttrib(self, attribs):
8384

8485
defserialize_html(input,options):
8586
options=dict([(str(k),v)fork,vinoptions.items()])
86-
stream=JsonWalker(input)
87+
stream=Lint(JsonWalker(input),False)
8788
serializer=HTMLSerializer(alphabetical_attributes=True,**options)
8889
returnserializer.render(stream,options.get("encoding",None))
8990

@@ -125,9 +126,6 @@ def testCharacters(self):
125126
deftestStartTagName(self):
126127
self.throwsWithLatin1([["StartTag","http://www.w3.org/1999/xhtml","\u0101", []]])
127128

128-
deftestEmptyTagName(self):
129-
self.throwsWithLatin1([["EmptyTag","http://www.w3.org/1999/xhtml","\u0101", []]])
130-
131129
deftestAttributeName(self):
132130
self.throwsWithLatin1([["StartTag","http://www.w3.org/1999/xhtml","span", [{"namespace":None,"name":"\u0101","value":"potato"}]]])
133131

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp