diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-27 13:52:11 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-27 13:52:11 -0500 |
commit | f503a773d851ca3a0f1b690e8065a445f34acca9 (patch) | |
tree | 170a9968ee69f4d7ce8d89c015eba55abceef826 /bs4/element.py | |
parent | f224b8536ce266538bcfa492ec8d2b3b41fceae5 (diff) |
Make prettify() return Unicode by default, so it will look nice when passed into print() under Python 3.
Diffstat (limited to 'bs4/element.py')
-rw-r--r-- | bs4/element.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bs4/element.py b/bs4/element.py index e50f639..650bacf 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -848,9 +848,11 @@ class Tag(PageElement): s = ''.join(s) return s - def prettify(self, encoding=DEFAULT_OUTPUT_ENCODING, - formatter="minimal"): - return self.encode(encoding, True, formatter) + def prettify(self, encoding=None, formatter="minimal"): + if encoding is None: + return self.decode(True, formatter=formatter) + else: + return self.encode(encoding, True, formatter=formatter) def decode_contents(self, indent_level=None, eventual_encoding=DEFAULT_OUTPUT_ENCODING, |