You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Ali Ijaz Sheikh b9445bfecd deps: update v8_inspector 9 years ago
..
bench deps: update v8_inspector 9 years ago
markupsafe deps: update v8_inspector 9 years ago
.gitignore deps: update v8_inspector 9 years ago
.travis.yml deps: update v8_inspector 9 years ago
AUTHORS deps: update v8_inspector 9 years ago
CHANGES deps: update v8_inspector 9 years ago
LICENSE deps: update v8_inspector 9 years ago
MANIFEST.in deps: update v8_inspector 9 years ago
Makefile deps: update v8_inspector 9 years ago
README.rst deps: update v8_inspector 9 years ago
setup.py deps: update v8_inspector 9 years ago
tox.ini deps: update v8_inspector 9 years ago

README.rst

MarkupSafe
==========

Implements a unicode subclass that supports HTML strings:

>>> from markupsafe import Markup, escape
>>> escape("<script>alert(document.cookie);</script>")
Markup(u'&lt;script&gt;alert(document.cookie);&lt;/script&gt;')
>>> tmpl = Markup("<em>%s</em>")
>>> tmpl % "Peter > Lustig"
Markup(u'<em>Peter &gt; Lustig</em>')

If you want to make an object unicode that is not yet unicode
but don't want to lose the taint information, you can use the
`soft_unicode` function. (On Python 3 you can also use `soft_str` which
is a different name for the same function).

>>> from markupsafe import soft_unicode
>>> soft_unicode(42)
u'42'
>>> soft_unicode(Markup('foo'))
Markup(u'foo')

HTML Representations
--------------------

Objects can customize their HTML markup equivalent by overriding
the `__html__` function:

>>> class Foo(object):
... def __html__(self):
... return '<strong>Nice</strong>'
...
>>> escape(Foo())
Markup(u'<strong>Nice</strong>')
>>> Markup(Foo())
Markup(u'<strong>Nice</strong>')