1 # -*- coding: utf-8 -*-
6 Native Python implementation the C module is not compiled.
8 :copyright: (c) 2010 by Armin Ronacher.
9 :license: BSD, see LICENSE for more details.
11 from jinja2._markupsafe import Markup
15 """Convert the characters &, <, >, ' and " in string s to HTML-safe
16 sequences. Use this if you need to display text that might contain
17 such characters in HTML. Marks return value as markup string.
19 if hasattr(s, '__html__'):
21 return Markup(unicode(s)
22 .replace('&', '&')
25 .replace("'", ''')
26 .replace('"', '"')
31 """Like :func:`escape` but converts `None` into an empty
40 """Make a string unicode if it isn't already. That way a markup
41 string is not converted back to unicode.
43 if not isinstance(s, unicode):