From 999a1ad671036ccbb4704d402dff624083fbee90 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sun, 15 Jul 2018 19:50:15 -0400 Subject: Introduced the Formatter system. [bug=1716272]. --- doc/source/index.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'doc/source/index.rst') 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:: # # + 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("
") + + print(soup.encode(formatter="html")) + #
+ + print(soup.encode(formatter="html5")) + #
+ 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:: -- cgit v1.2.1