File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`):
141141 argument is a list of ``(name, value) `` pairs containing the attributes found
142142 inside the tag's ``<> `` brackets. The *name * will be translated to lower case,
143143 and quotes in the *value * have been removed, and character and entity references
144- have been replaced.
144+ have been replaced. For empty attributes, * value * is `` None ``.
145145
146146 For instance, for the tag ``<A HREF="https://www.cwi.nl/"> ``, this method
147147 would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')]) ``.
@@ -317,6 +317,18 @@ without further parsing:
317317 Data : alert("<strong>hello! ☺</strong>");
318318 End tag : script
319319
320+ Attribute names are converted to lowercase, quotes from attribute values removed,
321+ and ``None `` is returned as *value * for empty attributes (such as ``checked ``):
322+
323+ .. doctest ::
324+
325+ >>> parser.feed(" <input TYPE='checkbox' checked required='' disabled=disabled>" )
326+ Start tag: input
327+ attr: ('type', 'checkbox')
328+ attr: ('checked', None)
329+ attr: ('required', '')
330+ attr: ('disabled', 'disabled')
331+
320332Parsing comments:
321333
322334.. doctest ::
You can’t perform that action at this time.
0 commit comments