diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 11:09:59 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-18 11:09:59 -0500 |
commit | ddf9d04e42168fdb25b742b35efc891789a4b6c9 (patch) | |
tree | c6ab873662cf1caba6364440d26ce5c0131d4c5d /beautifulsoup/builder/html5lib_builder.py | |
parent | 397483b981b7fe84d4f43dcb5c01268c3bf81602 (diff) |
Have the html5lib builder set the sniffed encoding after parsing, rather than before as happens with lxml.
Diffstat (limited to 'beautifulsoup/builder/html5lib_builder.py')
-rw-r--r-- | beautifulsoup/builder/html5lib_builder.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/beautifulsoup/builder/html5lib_builder.py b/beautifulsoup/builder/html5lib_builder.py index dc95493..a5aaa01 100644 --- a/beautifulsoup/builder/html5lib_builder.py +++ b/beautifulsoup/builder/html5lib_builder.py @@ -18,6 +18,9 @@ class HTML5TreeBuilder(HTMLTreeBuilder): parser = html5lib.HTMLParser(tree=self.create_treebuilder) doc = parser.parse(markup) + # Set the character encoding detected by the tokenizer. + doc.originalEncoding = parser.tokenizer.stream.charEncoding[0] + def create_treebuilder(self, namespaceHTMLElements): self.underlying_builder = TreeBuilderForHtml5lib( self.soup, namespaceHTMLElements) |