Take into account r1178 of HTML5's draft in the Python implementation… · dstufft/html5lib-python@54bb5ec · GitHub
Skip to content

Commit 54bb5ec

Browse files
committed
Take into account r1178 of HTML5's draft in the Python implementation (note that previous changes to the spec aren't yet implemented, this changeset doesn't thus make the implementation conforming to r1178, just to r1177-r1178 changes).
Adds tests for the "p" optional end tag, but not for the 'rt' and 'rp', neither for the parser changes (at least, they don't break existing tests) --HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401182
1 parent 2530b06 commit 54bb5ec

3 files changed

Lines changed: 50 additions & 18 deletions

File tree

src/html5lib/constants.py

Lines changed: 19 additions & 3 deletions

src/html5lib/filters/optionaltags.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,28 @@ def is_optional_end(self, tagname, next):
112112
return False
113113
elif tagname == 'p':
114114
# A p element's end tag may be omitted if the p element is
115-
# immediately followed by an address, blockquote, dl, fieldset,
116-
# form, h1, h2, h3, h4, h5, h6, hr, menu, ol, p, pre, table,
117-
# or ul element, or if there is no more content in the parent
118-
# element.
115+
# immediately followed by an address, article, aside,
116+
# blockquote, datagrid, dialog, dir, div, dl, fieldset,
117+
# footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu,
118+
# nav, ol, p, pre, section, table, or ul, element, or if
119+
# there is no more content in the parent element.
120+
if type == "StartTag":
121+
return next["name"] in ('address', 'article', 'aside', \
122+
'blockquote', 'datagrid', 'dialog', 'dir', 'div', \
123+
'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', \
124+
'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', \
125+
'p', 'pre', 'section', 'table', 'ul')
126+
else:
127+
return type == "EndTag" or type is None
128+
elif tagname in ('rt', 'rp'):
129+
# An rt element's end tag may be omitted if the rt element is
130+
# immediately followed by an rt or rp element, or if there is
131+
# no more content in the parent element.
132+
# An rp element's end tag may be omitted if the rp element is
133+
# immediately followed by an rt or rp element, or if there is
134+
# no more content in the parent element.
119135
if type == "StartTag":
120-
return next["name"] in ('address', 'blockquote', \
121-
'dl', 'fieldset', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', \
122-
'h6', 'hr', 'menu', 'ol', 'p', 'pre', 'table', 'ul')
136+
return next["name"] in ('rt', 'rp')
123137
else:
124138
return type == "EndTag" or type is None
125139
elif tagname == 'colgroup':

src/html5lib/html5parser.py

Lines changed: 10 additions & 8 deletions

0 commit comments

Comments
 (0)