From 7201eecc09b51df5a0fb704670aa66bcc9d8e635 Mon Sep 17 00:00:00 2001
From: Leonard Richardson
Date: Sun, 14 Feb 2021 15:34:04 -0500
Subject: The 'html5' formatter now treats attributes whose values are the
empty string as HTML boolean attributes. Previously (and in other
formatters), an attribute value must be set as None to be treated as a
boolean attribute. In a future release, I plan to also give this behavior
to the 'html' formatter. Patch by Isaac Muse. [bug=1915424]
---
doc/source/index.rst | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
(limited to 'doc')
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 8a1a2d5..2b5843d 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -2299,7 +2299,7 @@ Unicode characters to HTML entities whenever possible::
# Il a dit <<Sacré bleu!>>
#
-If you pass in ``formatter="html5"``, it's the same as
+If you pass in ``formatter="html5"``, it's similar to
``formatter="html"``, but Beautiful Soup will
omit the closing slash in HTML void tags like "br"::
@@ -2310,7 +2310,17 @@ omit the closing slash in HTML void tags like "br"::
print(br.encode(formatter="html5"))
# b' '
+
+In addition, any attributes whose values are the empty string
+will become HTML-style boolean attributes:
+
+ option = BeautifulSoup('').option
+ print(option.encode(formatter="html"))
+ # b''
+ print(option.encode(formatter="html5"))
+ # b''
+
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.3