makinacorpus/spynner — Issue #2: .text() also prints html comments content
Author: charlieman
Created: 2012-01-23 18:35:54+00:00
State: open

This is what currently happens:

>>> doc = PyQuery('

hello world

')
>>> print(doc.text())
hello foo world

But it should output "hello world".

A fix could be changing this in pyquery.py line 884:

if tag.text:
text.append(tag.text)

For this:

if tag.text and tag.tag != lxml.etree.Comment:
text.append(tag.text)

And import lxml.etree.Comment at the head