|
"Markup" | __new__ (cls, t.Any base="", t.Optional[str] encoding=None, str errors="strict") |
|
"Markup" | __html__ (self) |
|
"Markup" | __add__ (self, t.Union[str, "HasHTML"] other) |
|
"Markup" | __radd__ (self, t.Union[str, "HasHTML"] other) |
|
"Markup" | __mul__ (self, int num) |
|
"Markup" | __mod__ (self, t.Any arg) |
|
str | __repr__ (self) |
|
"Markup" | join (self, t.Iterable[t.Union[str, "HasHTML"]] seq) |
|
t.List["Markup"] | split (self, t.Optional[str] sep=None, int maxsplit=-1) |
|
t.List["Markup"] | rsplit (self, t.Optional[str] sep=None, int maxsplit=-1) |
|
t.List["Markup"] | splitlines (self, bool keepends=False) |
|
str | unescape (self) |
|
str | striptags (self) |
|
"Markup" | escape (cls, t.Any s) |
|
t.Tuple["Markup", "Markup", "Markup"] | partition (self, str sep) |
|
t.Tuple["Markup", "Markup", "Markup"] | rpartition (self, str sep) |
|
"Markup" | format (self, *t.Any args, **t.Any kwargs) |
|
"Markup" | __html_format__ (self, str format_spec) |
|
A string that is ready to be safely inserted into an HTML or XML
document, either because it was escaped or because it was marked
safe.
Passing an object to the constructor converts it to text and wraps
it to mark it safe without escaping. To escape the text, use the
:meth:`escape` class method instead.
>>> Markup("Hello, <em>World</em>!")
Markup('Hello, <em>World</em>!')
>>> Markup(42)
Markup('42')
>>> Markup.escape("Hello, <em>World</em>!")
Markup('Hello <em>World</em>!')
This implements the ``__html__()`` interface that some frameworks
use. Passing an object that implements ``__html__()`` will wrap the
output of that method, marking it safe.
>>> class Foo:
... def __html__(self):
... return '<a href="/foo">foo</a>'
...
>>> Markup(Foo())
Markup('<a href="/foo">foo</a>')
This is a subclass of :class:`str`. It has the same methods, but
escapes their arguments and returns a ``Markup`` instance.
>>> Markup("<em>%s</em>") % ("foo & bar",)
Markup('<em>foo & bar</em>')
>>> Markup("<em>Hello</em> ") + "<foo>"
Markup('<em>Hello</em> <foo>')