summaryrefslogtreecommitdiff
path: root/doc/source/index.rst
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2018-07-15 19:50:15 -0400
committerLeonard Richardson <leonardr@segfault.org>2018-07-15 19:50:15 -0400
commitad2850dfe321856331c939ad0f5c5a636a07091b (patch)
treea9b4ae0a151c9f470e7c7ce4703a6559e57c4dfd /doc/source/index.rst
parent03593ede7a56a5bfa21825f1e87187b0afccc620 (diff)
Introduced the Formatter system. [bug=1716272].
Diffstat (limited to 'doc/source/index.rst')
-rw-r--r--doc/source/index.rst14
1 files changed, 13 insertions, 1 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index e1b73aa..cc816a0 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -2145,7 +2145,7 @@ invalid HTML or XML::
You can change this behavior by providing a value for the
``formatter`` argument to ``prettify()``, ``encode()``, or
-``decode()``. Beautiful Soup recognizes four possible values for
+``decode()``. Beautiful Soup recognizes six possible values for
``formatter``.
The default is ``formatter="minimal"``. Strings will only be processed
@@ -2174,6 +2174,18 @@ Unicode characters to HTML entities whenever possible::
# </body>
# </html>
+ If you pass in ``formatter="html5"``, it's the same as
+``formatter="html5"``, but Beautiful Soup will
+omit the closing slash in HTML void tags like "br"::
+
+ soup = BeautifulSoup("<br>")
+
+ print(soup.encode(formatter="html"))
+ # <html><body><br/></body></html>
+
+ print(soup.encode(formatter="html5"))
+ # <html><body><br></body></html>
+
If you pass in ``formatter=None``, Beautiful Soup will not modify
strings at all on output. This is the fastest option, but it may lead
to Beautiful Soup generating invalid HTML/XML, as in these examples::