summaryrefslogtreecommitdiff
path: root/bs4/__init__.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2015-06-23 22:28:11 -0400
committerLeonard Richardson <leonardr@segfault.org>2015-06-23 22:28:11 -0400
commit1023fcb63bc75a3f41ca385b655d6943d1273278 (patch)
tree551755a7bf02218c8891e643e2e05c0243075c20 /bs4/__init__.py
parent81b0e7160db445f9d8fb8bf09ba306df87cac19e (diff)
Got a hacky fix for the latest html5lib problem.
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r--bs4/__init__.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py
index 9f602ae..cc4b27f 100644
--- a/bs4/__init__.py
+++ b/bs4/__init__.py
@@ -303,8 +303,25 @@ class BeautifulSoup(Tag):
"""Add an object to the parse tree."""
parent = parent or self.currentTag
most_recent_element = most_recent_element or self._most_recent_element
+
+ if isinstance(o, Tag):
+ next_element = o.next_element
+ next_sibling = o.next_sibling
+ previous_sibling = o.previous_sibling
+ previous_element = o.previous_element
+
o.setup(parent, most_recent_element)
+ if isinstance(o, Tag):
+ if next_element:
+ o.next_element = next_element
+ if next_sibling:
+ o.next_sibling = next_sibling
+ if previous_sibling:
+ o.previous_sibling = previous_sibling
+ if previous_element:
+ o.previous_element = previous_element
+
if most_recent_element is not None:
most_recent_element.next_element = o
self._most_recent_element = o