summaryrefslogtreecommitdiff
path: root/bs4/__init__.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2012-08-21 09:13:11 -0400
committerLeonard Richardson <leonardr@segfault.org>2012-08-21 09:13:11 -0400
commit1bdebd326cec9699cd18f040a32a79b8b925eb84 (patch)
treec33860d35fc43f81af423703130fbd7c68505c20 /bs4/__init__.py
parentd95ac0003965b4c70157d456fce4d5f1e03ab2d6 (diff)
Fixed a problem with the html5lib builder not handling comments correctly.
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r--bs4/__init__.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py
index 80f6f68..fe2656b 100644
--- a/bs4/__init__.py
+++ b/bs4/__init__.py
@@ -245,13 +245,15 @@ class BeautifulSoup(Tag):
o = containerClass(currentData)
self.object_was_parsed(o)
- def object_was_parsed(self, o):
+ def object_was_parsed(self, o, parent=None, previous_element=None):
"""Add an object to the parse tree."""
- o.setup(self.currentTag, self.previous_element)
+ parent = parent or self.currentTag
+ previous_element = previous_element or self.previous_element
+ o.setup(parent, previous_element)
if self.previous_element:
self.previous_element.next_element = o
self.previous_element = o
- self.currentTag.contents.append(o)
+ parent.contents.append(o)
def _popToTag(self, name, nsprefix=None, inclusivePop=True):
"""Pops the tag stack up to and including the most recent