diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-23 12:23:12 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-23 12:23:12 -0500 |
commit | fcefebe15290b9ff44934efa73fb07c70ebf5171 (patch) | |
tree | c0b3ae8837a96975e1b88f3e2e9befc07a72e70c /bs4/__init__.py | |
parent | b7749c50a2c96ccf6982cfa1ca02d883e31e0af9 (diff) |
Fixed handling of the closing of namespaced tags.
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r-- | bs4/__init__.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index bf800ea..9b5c155 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -249,7 +249,7 @@ class BeautifulSoup(Tag): self.previous_element = o self.currentTag.contents.append(o) - def _popToTag(self, name, inclusivePop=True): + def _popToTag(self, name, nsprefix=None, inclusivePop=True): """Pops the tag stack up to and including the most recent instance of the given tag. If inclusivePop is false, pops the tag stack up to but *not* including the most recent instqance of @@ -262,7 +262,8 @@ class BeautifulSoup(Tag): mostRecentTag = None for i in range(len(self.tagStack) - 1, 0, -1): - if name == self.tagStack[i].name: + if (name == self.tagStack[i].name + and nsprefix == self.tagStack[i].nsprefix == nsprefix): numPops = len(self.tagStack) - i break if not inclusivePop: @@ -299,10 +300,10 @@ class BeautifulSoup(Tag): self.pushTag(tag) return tag - def handle_endtag(self, name): + def handle_endtag(self, name, nsprefix=None): #print "End tag: " + name self.endData() - self._popToTag(name) + self._popToTag(name, nsprefix) def handle_data(self, data): self.currentData.append(data) |