summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-04-12 09:14:30 -0700
committerGitHub <noreply@github.com>2020-04-12 09:14:30 -0700
commitce2e28b599013dbc596e84d58647f4abafc83901 (patch)
tree69aaea69f1b6a756b2b89ec5e09b0c7b3472ff2d
parente7dba622cf5efe5a2c5ff98990ce4f72f50e70b2 (diff)
downloadmarkupsafe-ce2e28b599013dbc596e84d58647f4abafc83901.tar.gz
remove u prefix, split up example sections
-rw-r--r--README.rst10
1 files changed, 7 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 63ac13c..26f2e44 100644
--- a/README.rst
+++ b/README.rst
@@ -26,18 +26,22 @@ Examples
.. code-block:: pycon
>>> from markupsafe import Markup, escape
+
>>> # escape replaces special characters and wraps in Markup
>>> escape("<script>alert(document.cookie);</script>")
- Markup(u'&lt;script&gt;alert(document.cookie);&lt;/script&gt;')
+ Markup('&lt;script&gt;alert(document.cookie);&lt;/script&gt;')
+
>>> # wrap in Markup to mark text "safe" and prevent escaping
>>> Markup("<strong>Hello</strong>")
Markup('<strong>hello</strong>')
+
>>> escape(Markup("<strong>Hello</strong>"))
Markup('<strong>hello</strong>')
+
>>> # Markup is a str subclass
>>> # methods and operators escape their arguments
- >>> template = Markup("Hello <em>%s</em>")
- >>> template % ('"World"',)
+ >>> template = Markup("Hello <em>{name}</em>")
+ >>> template.format(name='"World"')
Markup('Hello <em>&#34;World&#34;</em>')