Open djay opened 8 years ago
I think there are two things going on.
For example this will get you the desired result
> doc = pq("<span/><div>foo</div>",parser='html_fragments')
> root = doc[0].getparent()
> print doc.filter("div").remove()
<div>foo</div>
> print (root.text or '') + ''.join([tostring(child) for child in root.iterchildren()])
<span/>
for example
The reason seems to be that replace_with expects a parent, which exists, but is not part of the original document.
Remove doesn't work either