summaryrefslogtreecommitdiff
path: root/beautifulsoup/builder/html5lib_builder.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-18 09:58:07 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-18 09:58:07 -0500
commit66cbef12d959149746b3361f227f2a0328a31469 (patch)
treec6772c648933ad1477dc642aa598f34508870fff /beautifulsoup/builder/html5lib_builder.py
parentcb85520f7627a914e10e2d3ea52d7066bdf3984d (diff)
parentd9462ef1b2760ccb6273903abcd7d253445716a4 (diff)
Refactored the code that sets up substitutions in attribute values, and made content-type substitution work with html5lib.
Diffstat (limited to 'beautifulsoup/builder/html5lib_builder.py')
-rw-r--r--beautifulsoup/builder/html5lib_builder.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/beautifulsoup/builder/html5lib_builder.py b/beautifulsoup/builder/html5lib_builder.py
index 736889f..dc95493 100644
--- a/beautifulsoup/builder/html5lib_builder.py
+++ b/beautifulsoup/builder/html5lib_builder.py
@@ -130,12 +130,19 @@ class Element(html5lib.treebuilders._base.Node):
return AttrList(self.element)
def setAttributes(self, attributes):
- if attributes:
+ if attributes is not None and attributes != {}:
for name, value in attributes.items():
self.element[name] = value
-
+ # The attributes may contain variables that need substitution.
+ # Call set_up_substitutions manually.
+ # The Tag constructor calls this method automatically,
+ # but html5lib creates a Tag object before setting up
+ # the attributes.
+ self.element.contains_substitutions = (
+ self.soup.builder.set_up_substitutions(
+ self.element))
attributes = property(getAttributes, setAttributes)
-
+
def insertText(self, data, insertBefore=None):
text = TextNode(NavigableString(data), self.soup)
if insertBefore: