mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
BeautifulSoup: Fix bug in extract() method that prevented extraction of identical individual tags
This commit is contained in:
parent
a031f04e91
commit
9fa6e8abe2
@ -129,11 +129,16 @@ class PageElement:
|
||||
|
||||
def extract(self):
|
||||
"""Destructively rips this element out of the tree."""
|
||||
# Changed by KG as list.remove uses _-eq__ which is True for two Tags
|
||||
# with the same name and attributes.
|
||||
if self.parent:
|
||||
try:
|
||||
self.parent.contents.remove(self)
|
||||
except ValueError:
|
||||
pass
|
||||
idx = None
|
||||
for i, x in enumerate(self.parent.contents):
|
||||
if x is self:
|
||||
idx = i
|
||||
break
|
||||
if idx is not None:
|
||||
self.parent.contents.pop(idx)
|
||||
|
||||
#Find the two elements that would be next to each other if
|
||||
#this element (and any children) hadn't been parsed. Connect
|
||||
|
Loading…
x
Reference in New Issue
Block a user