diff options
-rw-r--r-- | NEWS.txt | 13 | ||||
-rw-r--r-- | bs4/element.py | 18 |
2 files changed, 25 insertions, 6 deletions
@@ -7,6 +7,12 @@ * Fixed yet another problem that caused the html5lib tree builder to create a disconnected parse tree. [bug=1237763] +* Force object_was_parsed() to keep the tree intact even when an element + from later in the document is moved into place. [bug=1430633] + +* Fixed yet another bug that caused a disconnected tree when html5lib + copied an element from one part of the tree to another. [bug=1270611] + * The select() method now supports selector grouping. Patch by Francisco Canas [bug=1191917] @@ -31,11 +37,8 @@ displayed correctly even if the filename or URL is a Unicode string. [bug=1268888] -* Force object_was_parsed() to keep the tree intact even when an element - from later in the document is moved into place. [bug=1430633] - -* Fixed yet another bug that caused a disconnected tree when html5lib - copied an element from one part of the tree to another. [bug=1270611] +* Improved docstring for encode_contents() and + decode_contents(). [bug=1441543] = 4.3.2 (20131002) = diff --git a/bs4/element.py b/bs4/element.py index 9dc7b47..0c2e11a 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -1115,12 +1115,18 @@ class Tag(PageElement): formatter="minimal"): """Renders the contents of this tag as a Unicode string. + :param indent_level: Each line of the rendering will be + indented this many spaces. + :param eventual_encoding: The tag is destined to be encoded into this encoding. This method is _not_ responsible for performing that encoding. This information is passed in so that it can be substituted in if the document contains a <META> tag that mentions the document's encoding. + + :param formatter: The output formatter responsible for converting + entities to Unicode characters. """ # First off, turn a string formatter into a function. This # will stop the lookup from happening over and over again. @@ -1149,7 +1155,17 @@ class Tag(PageElement): def encode_contents( self, indent_level=None, encoding=DEFAULT_OUTPUT_ENCODING, formatter="minimal"): - """Renders the contents of this tag as a bytestring.""" + """Renders the contents of this tag as a bytestring. + + :param indent_level: Each line of the rendering will be + indented this many spaces. + + :param eventual_encoding: The bytestring will be in this encoding. + + :param formatter: The output formatter responsible for converting + entities to Unicode characters. + """ + contents = self.decode_contents(indent_level, encoding, formatter) return contents.encode(encoding) |