Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-82665 Mention that HTMLParser.handle_starttag value can be None #134312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion 13 Doc/library/html.parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`):
argument is a list of ``(name, value)`` pairs containing the attributes found
inside the tag's ``<>`` brackets. The *name* will be translated to lower case,
and quotes in the *value* have been removed, and character and entity references
have been replaced.
have been replaced. If a boolean attribute is encountered, the *value* for the
``(name, value)`` attribute pair will be ``None``.

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

Boolean attributes have a *value* of ``None``:

.. doctest::

>>> parser.feed("<script src='/script.js' defer></script>")
Start tag: script
attr: ('src', '/script.js')
attr: ('defer', None)
End tag : script

Parsing comments:

.. doctest::
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.