Skip to content

Commit 9971a24

Browse files
Polish the documentation.
1 parent a46e28b commit 9971a24

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

Doc/library/html.parser.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.
1919

2020
Create a parser instance able to parse invalid markup.
2121

22-
If *convert_charrefs* is ``True`` (the default), all character
23-
references (except the ones in RAWTEXT tags) are
22+
If *convert_charrefs* is true (the default), all character
23+
references (except the ones in elements like ``script`` and ``style``) are
2424
automatically converted to the corresponding Unicode characters.
2525

26-
If *scripting* is false (the default), the content of the ``noscript`` element
27-
is parsed normally; if it's true, it's parsed in RAWTEXT mode.
26+
If *scripting* is false (the default), the content of the ``noscript``
27+
element is parsed normally; if it's true, it's parsed in RAWTEXT mode,
28+
like ``script``.
2829

2930
An :class:`.HTMLParser` instance is fed HTML data and calls handler methods
3031
when start tags, end tags, text, comments, and other markup elements are
@@ -167,24 +168,24 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`):
167168
.. method:: HTMLParser.handle_data(data)
168169

169170
This method is called to process arbitrary data (e.g. text nodes and the
170-
content of ``<script>...</script>`` and ``<style>...</style>``).
171+
content of elements like ``script`` and ``style``).
171172

172173

173174
.. method:: HTMLParser.handle_entityref(name)
174175

175176
This method is called to process a named character reference of the form
176177
``&name;`` (e.g. ``&gt;``), where *name* is a general entity reference
177-
(e.g. ``'gt'``). This method is never called if *convert_charrefs* is
178-
``True``.
178+
(e.g. ``'gt'``).
179+
This method is only called if *convert_charrefs* is false.
179180

180181

181182
.. method:: HTMLParser.handle_charref(name)
182183

183184
This method is called to process decimal and hexadecimal numeric character
184185
references of the form :samp:`&#{NNN};` and :samp:`&#x{NNN};`. For example, the decimal
185186
equivalent for ``&gt;`` is ``&#62;``, whereas the hexadecimal is ``&#x3E;``;
186-
in this case the method will receive ``'62'`` or ``'x3E'``. This method
187-
is never called if *convert_charrefs* is ``True``.
187+
in this case the method will receive ``'62'`` or ``'x3E'``.
188+
This method is only called if *convert_charrefs* is false.
188189

189190

190191
.. method:: HTMLParser.handle_comment(data)
@@ -298,8 +299,8 @@ Parsing an element with a few attributes and a title:
298299
Data : Python
299300
End tag : h1
300301

301-
The content of ``script`` and ``style`` elements is returned as is, without
302-
further parsing:
302+
The content of elements like ``script`` and ``style`` is returned as is,
303+
without further parsing:
303304

304305
.. doctest::
305306

@@ -310,10 +311,10 @@ further parsing:
310311
End tag : style
311312

312313
>>> parser.feed('<script type="text/javascript">'
313-
... 'alert("<strong>hello!</strong>");</script>')
314+
... 'alert("<strong>hello! &#9786;</strong>");</script>')
314315
Start tag: script
315316
attr: ('type', 'text/javascript')
316-
Data : alert("<strong>hello!</strong>");
317+
Data : alert("<strong>hello! &#9786;</strong>");
317318
End tag : script
318319

319320
Parsing comments:
@@ -342,7 +343,7 @@ correct char (note: these 3 references are all equivalent to ``'>'``):
342343

343344
Feeding incomplete chunks to :meth:`~HTMLParser.feed` works, but
344345
:meth:`~HTMLParser.handle_data` might be called more than once
345-
(unless *convert_charrefs* is set to ``True``):
346+
if *convert_charrefs* is false:
346347

347348
.. doctest::
348349

0 commit comments

Comments
 (0)