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):
|
def extract(self):
|
||||||
"""Destructively rips this element out of the tree."""
|
"""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:
|
if self.parent:
|
||||||
try:
|
idx = None
|
||||||
self.parent.contents.remove(self)
|
for i, x in enumerate(self.parent.contents):
|
||||||
except ValueError:
|
if x is self:
|
||||||
pass
|
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
|
#Find the two elements that would be next to each other if
|
||||||
#this element (and any children) hadn't been parsed. Connect
|
#this element (and any children) hadn't been parsed. Connect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user