diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 11:29:43 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 11:29:43 -0500 |
commit | 75c5891980c961dfe36745c1934010560666f938 (patch) | |
tree | fa62ea107db97916fa538883ae561fba64ea13d9 /beautifulsoup/builder | |
parent | ddf9d04e42168fdb25b742b35efc891789a4b6c9 (diff) |
Pass the user-specified encoding in to html5lib rather than dropping it on the floor.
Diffstat (limited to 'beautifulsoup/builder')
-rw-r--r-- | beautifulsoup/builder/html5lib_builder.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/beautifulsoup/builder/html5lib_builder.py b/beautifulsoup/builder/html5lib_builder.py index a5aaa01..bb0e374 100644 --- a/beautifulsoup/builder/html5lib_builder.py +++ b/beautifulsoup/builder/html5lib_builder.py @@ -13,10 +13,15 @@ from beautifulsoup.element import ( class HTML5TreeBuilder(HTMLTreeBuilder): """Use html5lib to build a tree.""" + def prepare_markup(self, markup, user_specified_encoding): + # Store the user-specified encoding for use later on. + self.user_specified_encoding = user_specified_encoding + return markup, None, None + # These methods are defined by Beautiful Soup. def feed(self, markup): parser = html5lib.HTMLParser(tree=self.create_treebuilder) - doc = parser.parse(markup) + doc = parser.parse(markup, encoding=self.user_specified_encoding) # Set the character encoding detected by the tokenizer. doc.originalEncoding = parser.tokenizer.stream.charEncoding[0] |