1. Luke Plant
  2. pyquery


Christian Wyglendowski  committed 2eb6e16 Merge

Merged extra traversal stuff with the text() fix.

  • Participants
  • Parent commits dd74995, 43d3b70
  • Branches default

Comments (0)

Files changed (1)

File pyquery/pyquery.py

View file
  • Ignore whitespace
     def text(self, value=no_default):
         """return the text representation of sub nodes
-        def get_text(tag):
+        def get_text(tag, no_tail=False):
             text = []
             if tag.text:
             for child in tag.getchildren():
-            if tag.tail:
+            if not no_tail and tag.tail:
             return text
         if value is no_default:
             if not self:
                 return None
-            return ' '.join([''.join(get_text(tag)).strip() for tag in self])
+            return ' '.join([''.join(get_text(tag, no_tail=True)).strip()
+                             for tag in self])
         for tag in self:
             for child in tag.getchildren():