Escape the string. Works like :func:`escape` with the difference that for subclasses of :class:`Markup` this function would return the correct subclass.
(cls, s)
| 155 | |
| 156 | @classmethod |
| 157 | def escape(cls, s): |
| 158 | """Escape the string. Works like :func:`escape` with the difference |
| 159 | that for subclasses of :class:`Markup` this function would return the |
| 160 | correct subclass. |
| 161 | """ |
| 162 | rv = escape(s) |
| 163 | if rv.__class__ is not cls: |
| 164 | return cls(rv) |
| 165 | return rv |
| 166 | |
| 167 | def make_wrapper(name): |
| 168 | orig = getattr(text_type, name) |