2from typing
import TYPE_CHECKING, Optional, Union
4from .jupyter
import JupyterMixin
5from .segment
import Segment
6from .style
import Style
7from ._emoji_codes
import EMOJI
8from ._emoji_replace
import _emoji_replace
11 from typing
import Literal
17 from .console
import Console, ConsoleOptions, RenderResult
20EmojiVariant = Literal[
"emoji",
"text"]
24 """No emoji by that name."""
28 __slots__ = [
"name",
"style",
"_char",
"variant"]
30 VARIANTS = {
"text":
"\uFE0E",
"emoji":
"\uFE0F"}
35 style: Union[str, Style] =
"none",
36 variant: Optional[EmojiVariant] =
None,
38 """A single emoji character.
41 name (str): Name of emoji.
42 style (Union[str, Style], optional): Optional style. Defaults to None.
45 NoEmoji: If the emoji doesn't exist.
53 raise NoEmoji(f
"No emoji called {name!r}")
54 if variant
is not None:
58 def replace(cls, text: str) -> str:
59 """Replace emoji markup with corresponding unicode characters.
62 text (str): A string with emojis codes, e.g. "Hello :smiley:!"
65 str: A string with emoji codes replaces with actual emoji.
67 return _emoji_replace(text)
70 return f
"<emoji {self.name!r}>"
76 self, console:
"Console", options:
"ConsoleOptions"
81if __name__ ==
"__main__":
90 (f
":{name}: {name}" for name
in sorted(
EMOJI.keys())
if "\u200D" not in name),
None __init__(self, str name, Union[str, Style] style="none", Optional[EmojiVariant] variant=None)
"RenderResult" __rich_console__(self, "Console" console, "ConsoleOptions" options)