File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,7 +134,8 @@ 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.
137+ have been replaced. If a boolean attribute is encountered, the *value * for the
138+ ``(name, value) `` attribute pair will be ``None ``.
138139
139140 For instance, for the tag ``<A HREF="https://www.cwi.nl/"> ``, this method
140141 would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')]) ``.
@@ -310,6 +311,16 @@ further parsing:
310311 Data : alert("<strong>hello!</strong>");
311312 End tag : script
312313
314+ Boolean attributes have a *value * of ``None ``:
315+
316+ .. doctest ::
317+
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
323+
313324Parsing comments:
314325
315326.. doctest ::
You can’t perform that action at this time.
0 commit comments