Message252234
handle_startendtag is also called for non-void elements, such as <a/>, so
the override example will break in those situation.
The compatible patch I proposed right now is just one liner checker:
# http://www.w3.org/TR/html5/syntax.html#void-elements
<https://www.google.com/url?q=http://www.w3.org/TR/html5/syntax.html%23void-elements&usg=AFQjCNFVtfyZ53NDOHlPq896qmX5b8fPTA>_VOID_ELEMENT_TAGS
= frozenset([ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img',
'input', 'keygen', 'link', 'meta', 'param', 'source', 'track',
'wbr'])class HTMLParser.HTMLParser: # Internal -- handle starttag,
return end or -1 if not terminated def parse_starttag(self, i):
#... if end.endswith('/>'): # XHTML-style empty tag: <span
attr="value" /> self.handle_startendtag(tag, attrs)
############# PATCH ################# elif end.endswith('>')
and tag in _VOID_ELEMENT_TAGS: self.handle_startendtag(tag,
attrs) ############# PATCH ################# |
|
Date |
User |
Action |
Args |
2015-10-03 19:43:29 | Chenyun Yang | set | recipients:
+ Chenyun Yang, ezio.melotti, r.david.murray, martin.panter, josh.r, xiang.zhang |
2015-10-03 19:43:29 | Chenyun Yang | link | issue25258 messages |
2015-10-03 19:43:28 | Chenyun Yang | create | |
|