From d9462ef1b2760ccb6273903abcd7d253445716a4 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Fri, 18 Feb 2011 09:56:43 -0500 Subject: Yay, meta tag rewrites now work with html5lib. --- beautifulsoup/builder/html5lib_builder.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'beautifulsoup/builder/html5lib_builder.py') 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: -- cgit v1.2.3