| 1 |
:mod:`!html` --- HyperText Markup Language support |
| 2 |
================================================== |
| 3 |
|
| 4 |
.. module:: html |
| 5 |
:synopsis: Helpers for manipulating HTML. |
| 6 |
|
| 7 |
**Source code:** :source:`Lib/html/__init__.py` |
| 8 |
|
| 9 |
-------------- |
| 10 |
|
| 11 |
This module defines utilities to manipulate HTML. |
| 12 |
|
| 13 |
.. function:: escape(s, quote=True) |
| 14 |
|
| 15 |
Convert the characters ``&``, ``<`` and ``>`` in string *s* to HTML-safe |
| 16 |
sequences. Use this if you need to display text that might contain such |
| 17 |
characters in HTML. If the optional flag *quote* is true (the default), the |
| 18 |
characters (``"``) and (``'``) are also translated; this helps for inclusion |
| 19 |
in an HTML attribute value delimited by quotes, as in ``<a href="...">``. |
| 20 |
If *quote* is set to false, the characters (``"``) and (``'``) are not |
| 21 |
translated. |
| 22 |
|
| 23 |
|
| 24 |
.. versionadded:: 3.2 |
| 25 |
|
| 26 |
|
| 27 |
.. function:: unescape(s) |
| 28 |
|
| 29 |
Convert all named and numeric character references (e.g. ``>``, |
| 30 |
``>``, ``>``) in the string *s* to the corresponding Unicode |
| 31 |
characters. This function uses the rules defined by the HTML 5 standard |
| 32 |
for both valid and invalid character references, and the :data:`list of |
| 33 |
HTML 5 named character references <html.entities.html5>`. |
| 34 |
|
| 35 |
.. versionadded:: 3.4 |
| 36 |
|
| 37 |
-------------- |
| 38 |
|
| 39 |
Submodules in the ``html`` package are: |
| 40 |
|
| 41 |
* :mod:`html.parser` -- HTML/XHTML parser with lenient parsing mode |
| 42 |
* :mod:`html.entities` -- HTML entity definitions |