MarkupSafe
Implements a unicode subclass that supports HTML strings:
>>> from markupsafe import Markup, escape
>>> escape("<script>alert(document.cookie);</script>")
Markup(u'<script>alert(document.cookie);</script>')
>>> tmpl = Markup("<em>%s</em>")
>>> tmpl % "Peter > Lustig"
Markup(u'<em>Peter > 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:
>>> from markupsafe import soft_unicode
>>> soft_unicode(42)
u'42'
>>> soft_unicode(Markup('foo'))
Markup(u'foo')
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>')
Metadata
Release files for MarkupSafe 0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| MarkupSafe-0.9.tar.gz | 10.4 kB | Details |
Release files / MarkupSafe-0.9.tar.gz
| Download URL | MarkupSafe-0.9.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d84526bcfb6435d30cdb3531e3c43170d77107531a6d695c12a9c126ac09766
|
|
BLAKE2b-256 checksum How to use checksums |
be307dfaf5f61e9648a9bb97ecd0099da2546ea78fe93cb9c777030c6d056c0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |