| Index: Lib/html/__init__.py |
| =================================================================== |
| --- Lib/html/__init__.py (revision 84355) |
| +++ Lib/html/__init__.py (working copy) |
| @@ -1 +1,13 @@ |
| -# This directory is a Python package. |
| +"""Helper functions for HTML manipulation.""" |
| + |
| +def escape(s, quote=None): |
| + """Replace special characters "&", "<" and ">" to HTML-safe sequences. |
| + If the optional flag quote is true, the quotation mark character (") |
| + is also translated.""" |
| + s = s.replace("&", "&") # Must be done first! |
| + s = s.replace("<", "<") |
| + s = s.replace(">", ">") |
| + if quote: |
| + s = s.replace('"', """) |
| + s = s.replace('\'', "'") |
| + return s |