Georg Brandl | 1f7fffb | 2010-10-15 15:57:45 +0000 | [diff] [blame] | 1 | :mod:`html` --- HyperText Markup Language support |
| 2 | ================================================= |
| 3 | |
| 4 | .. module:: html |
| 5 | :synopsis: Helpers for manipulating HTML. |
| 6 | |
Raymond Hettinger | a199368 | 2011-01-27 01:20:32 +0000 | [diff] [blame] | 7 | **Source code:** :source:`Lib/html/__init__.py` |
| 8 | |
| 9 | -------------- |
Georg Brandl | 1f7fffb | 2010-10-15 15:57:45 +0000 | [diff] [blame] | 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 characters |
| 18 | (``"``) and (``'``) are also translated; this helps for inclusion in an HTML |
| 19 | attribute value delimited by quotes, as in ``<a href="...">``. |
Georg Brandl | 2c58075 | 2012-04-11 18:33:17 +0200 | [diff] [blame] | 20 | |
| 21 | .. versionadded:: 3.2 |
Georg Brandl | fe7b00f | 2012-10-06 13:49:34 +0200 | [diff] [blame] | 22 | |
Ezio Melotti | 4a9ee26 | 2013-11-19 20:28:45 +0200 | [diff] [blame] | 23 | |
| 24 | .. function:: unescape(s) |
| 25 | |
| 26 | Convert all named and numeric character references (e.g. ``>``, |
| 27 | ``>``, ``&x3e;``) in the string *s* to the corresponding unicode |
| 28 | characters. This function uses the rules defined by the HTML 5 standard |
| 29 | for both valid and invalid character references, and the :data:`list of |
| 30 | HTML 5 named character references <html.entities.html5>`. |
| 31 | |
| 32 | .. versionadded:: 3.4 |
| 33 | |
Georg Brandl | fe7b00f | 2012-10-06 13:49:34 +0200 | [diff] [blame] | 34 | -------------- |
| 35 | |
| 36 | Submodules in the ``html`` package are: |
| 37 | |
| 38 | * :mod:`html.parser` -- HTML/XHTML parser with lenient parsing mode |
| 39 | * :mod:`html.entities` -- HTML entity definitions |