pyquery
pyquery copied to clipboard
Sub-nodes are coupled with contents() method
contents() method is extremely useful to deal with a node that has text node child. However, it seems that can't generate correct childnodes in that following case. Consider
from pyquery import PyQuery as pq
html = '''<span>123<br>...456<br>...789</span>'''
doc = pq(html)
childnodes = doc.contents()
print('sub-node count by contents(): ', childnodes.size())
for childnode in childnodes.items():
pass
print(childnode)
It will yield
<p>123</p>
<br/>...456
<p>...456</p>
<br/>...789
<p>...789</p>
We can find that the 2nd sub-node and the 3rd one are coupled, and so are the 4th and the 5th. I am not sure it is a bug. Can anybody have a look at this? In addition, why the original text nodes are wrapped with a
tag automatically? It seems a redundant action.