Skip to content

Commit 329327b

Browse files
Tweak wording and example
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
1 parent 34d95f2 commit 329327b

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Doc/library/html.parser.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`):
134134
argument is a list of ``(name, value)`` pairs containing the attributes found
135135
inside the tag's ``<>`` brackets. The *name* will be translated to lower case,
136136
and quotes in the *value* have been removed, and character and entity references
137-
have been replaced. If a boolean attribute is encountered, the *value* for the
138-
``(name, value)`` attribute pair will be ``None``.
137+
have been replaced. For empty attributes, *value* is ``None``.
139138

140139
For instance, for the tag ``<A HREF="https://www.cwi.nl/">``, this method
141140
would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``.
@@ -311,15 +310,17 @@ further parsing:
311310
Data : alert("<strong>hello!</strong>");
312311
End tag : script
313312

314-
Boolean attributes have a *value* of ``None``:
313+
Attribute names are converted to lowercase, quotes from attribute values removed,
314+
and ``None`` is returned as *value* for empty attributes (such as `checked`):
315315

316316
.. doctest::
317317

318-
>>> parser.feed("<script src='/script.js' defer></script>")
319-
Start tag: script
320-
attr: ('src', '/script.js')
321-
attr: ('defer', None)
322-
End tag : script
318+
>>> parser.feed("<input TYPE='checkbox' checked required='' disabled=disabled>")
319+
Start tag: input
320+
attr: ('type', 'checkbox')
321+
attr: ('checked', None)
322+
attr: ('required', '')
323+
attr: ('disabled', 'disabled')
323324

324325
Parsing comments:
325326

0 commit comments

Comments
 (0)