summaryrefslogtreecommitdiff
path: root/beautifulsoup/__init__.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-26 23:40:06 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-26 23:40:06 -0500
commitace32031ac6c9787ee46c5ab19e6f71b99cd26d3 (patch)
tree624e46ced60e7f5cb55edcab5b3d93bddd804c28 /beautifulsoup/__init__.py
parent1f4733fd1215411752c4d793d93edbc007fece12 (diff)
parent8a6e1b5e15368c9dd66b6b407b7328c2bd0360ad (diff)
Cleaned up the pretty-print and attribute handling code.
Diffstat (limited to 'beautifulsoup/__init__.py')
-rw-r--r--beautifulsoup/__init__.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/beautifulsoup/__init__.py b/beautifulsoup/__init__.py
index cee55e7..53130e0 100644
--- a/beautifulsoup/__init__.py
+++ b/beautifulsoup/__init__.py
@@ -262,8 +262,9 @@ class BeautifulSoup(Tag):
def handle_data(self, data):
self.currentData.append(data)
- def decode(self, pretty_print=False, indent_level=0,
- eventual_encoding=DEFAULT_OUTPUT_ENCODING):
+ def decode(self, pretty_print=False,
+ eventual_encoding=DEFAULT_OUTPUT_ENCODING,
+ substitute_html_entities=False):
"""Returns a string or Unicode representation of this document.
To get Unicode, pass None for encoding."""
if self.is_xml:
@@ -274,8 +275,13 @@ class BeautifulSoup(Tag):
prefix = u'<?xml version="1.0"%s>\n' % encoding_part
else:
prefix = u''
+ if not pretty_print:
+ indent_level = None
+ else:
+ indent_level = 0
return prefix + super(BeautifulSoup, self).decode(
- pretty_print, indent_level, eventual_encoding)
+ indent_level, eventual_encoding,
+ substitute_html_entities)
class StopParsing(Exception):