Index: src/lxml/html/diff.py =================================================================== --- src/lxml/html/diff.py (版本 52472) +++ src/lxml/html/diff.py (工作副本) @@ -310,8 +310,8 @@ endtag = chunk[1] == '/' name = chunk.split()[0].strip('<>/') if name in empty_tags: - assert not endtag, ( - "Empty tag %r should have no end tag" % chunk) +# assert not endtag, ( +# "Empty tag %r should have no end tag" % chunk) balanced.append(chunk) continue if endtag: @@ -669,16 +669,15 @@ yield ('img', el.attrib['src'], start_tag(el)) else: yield start_tag(el) - if el.tag in empty_tags and not el.text and not len(el): - return - start_words = split_words(el.text) - for word in start_words: - yield cgi.escape(word) - for child in el: - for item in flatten_el(child, include_hrefs=include_hrefs): - yield item - if el.tag == 'a' and el.attrib.get('href') and include_hrefs: - yield ('href', el.attrib['href']) + if not (el.tag in empty_tags and not el.text and not len(el)): + start_words = split_words(el.text) + for word in start_words: + yield cgi.escape(word) + for child in el: + for item in flatten_el(child, include_hrefs=include_hrefs): + yield item + if el.tag == 'a' and el.attrib.get('href') and include_hrefs: + yield ('href', el.attrib['href']) if not skip_tag: yield end_tag(el) end_words = split_words(el.tail)