1.. currentmodule:: markupsafe
2
3MarkupSafe
4==========
5
6MarkupSafe escapes characters so text is safe to use in HTML and XML.
7Characters that have special meanings are replaced so that they display
8as the actual characters. This mitigates injection attacks, meaning
9untrusted user input can safely be displayed on a page.
10
11The :func:`escape` function escapes text and returns a :class:`Markup`
12object. The object won't be escaped anymore, but any text that is used
13with it will be, ensuring that the result remains safe to use in HTML.
14
15>>> from markupsafe import escape
16>>> hello = escape("<em>Hello</em>")
17>>> hello
18Markup('&lt;em&gt;Hello&lt;/em&gt;')
19>>> escape(hello)
20Markup('&lt;em&gt;Hello&lt;/em&gt;')
21>>> hello + " <strong>World</strong>"
22Markup('&lt;em&gt;Hello&lt;/em&gt; &lt;strong&gt;World&lt;/strong&gt;')
23
24
25Installing
26----------
27
28Install and update using `pip`_:
29
30.. code-block:: text
31
32    pip install -U MarkupSafe
33
34.. _pip: https://pip.pypa.io/en/stable/quickstart/
35
36
37Table of Contents
38-----------------
39
40.. toctree::
41    :maxdepth: 2
42
43    escaping
44    html
45    formatting
46    license
47    changes
48