summaryrefslogtreecommitdiff
path: root/beautifulsoup/builder/html5lib_builder.py
diff options
context:
space:
mode:
Diffstat (limited to 'beautifulsoup/builder/html5lib_builder.py')
-rw-r--r--beautifulsoup/builder/html5lib_builder.py7
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]