Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
markupsafe.Markup Class Reference
Inheritance diagram for markupsafe.Markup:
Inheritance graph
[legend]
Collaboration diagram for markupsafe.Markup:
Collaboration graph
[legend]

Public Member Functions

"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)
 

Public Attributes

 escape
 

Detailed Description

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 &lt;em&gt;World&lt;/em&gt;!')

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 &amp; bar</em>')
>>> Markup("<em>Hello</em> ") + "<foo>"
Markup('<em>Hello</em> &lt;foo&gt;')

Member Function Documentation

◆ escape()

"Markup" markupsafe.Markup.escape (   cls,
t.Any  s 
)
Escape a string. Calls :func:`escape` and ensures that for
subclasses the correct type is returned.

◆ striptags()

str markupsafe.Markup.striptags (   self)
:meth:`unescape` the markup, remove tags, and normalize
whitespace to single spaces.

>>> Markup("Main &raquo;\t<em>About</em>").striptags()
'Main » About'

◆ unescape()

str markupsafe.Markup.unescape (   self)
Convert escaped markup back into a text string. This replaces
HTML entities with the characters they represent.

>>> Markup("Main &raquo; <em>About</em>").unescape()
'Main » <em>About</em>'

The documentation for this class was generated from the following file: