diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 09:34:47 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 09:34:47 -0500 |
commit | 4ccc7c021d86ab648925072b9d4d3682587c5be8 (patch) | |
tree | 8d4695687e979b715642e55f60ca3dcd807a88de /beautifulsoup/element.py | |
parent | fcb11108f0c7913c0ab0d2f60bbff0f96ca5c16b (diff) |
Moved the substitution code to the Tag constructor so that we don't have to rely on handle_starttag to trigger it.
Diffstat (limited to 'beautifulsoup/element.py')
-rw-r--r-- | beautifulsoup/element.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/beautifulsoup/element.py b/beautifulsoup/element.py index 39e0e06..6e2bada 100644 --- a/beautifulsoup/element.py +++ b/beautifulsoup/element.py @@ -438,13 +438,16 @@ class Tag(PageElement, Entities): self.contents = [] self.setup(parent, previous) self.hidden = False - self.containsSubstitutions = False if isinstance(attrs, types.DictType): self.attrs = [kv for kv in attrs.items()] else: self.attrs = list(attrs) + # Set up any substitutions, such as the charset in a META tag. + self.contains_substitutions = builder.set_up_substitutions(self) + + @property def string(self): """Convenience property to get the single string within this tag. @@ -581,7 +584,7 @@ class Tag(PageElement, Entities): for key, val in self.attrs: fmt = '%s="%s"' if isString(val): - if (self.containsSubstitutions + if (self.contains_substitutions and eventualEncoding is not None and '%SOUP-ENCODING%' in val): val = self.substituteEncoding(val, eventualEncoding) @@ -882,6 +885,7 @@ class SoupStrainer: result = matchAgainst == markup return result + class ResultSet(list): """A ResultSet is just a list that keeps track of the SoupStrainer that created it.""" |