Method: rich.console.Console.render_str
Calls: 1274, Exceptions: 0, Paths: 4Back
Path 1: 1053 calls (0.83)
'' (225) 'foo' (95) 'Averlongwordgoeshere' (68) 'bar' (59) 'banana pancakes' (54) 'baz' (52) 'Coffee' (48) 'COL1' (24) 'test table' (21) 'table captio...
'' (1010) 'table.title' (22) 'table.caption' (21)
None (1053)
None (1053)
None (1053)
None (1053)
False (1053)
None (1053)
Text (1053)
1def render_str(
2 self,
3 text: str,
4 *,
5 style: Union[str, Style] = "",
6 justify: Optional[JustifyMethod] = None,
7 overflow: Optional[OverflowMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 highlighter: Optional[HighlighterType] = None,
12 ) -> "Text":
13 """Convert a string to a Text instance. This is called automatically if
14 you print or log a string.
15
16 Args:
17 text (str): Text to render.
18 style (Union[str, Style], optional): Style to apply to rendered text.
19 justify (str, optional): Justify method: "default", "left", "center", "full", or "right". Defaults to ``None``.
20 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to ``None``.
21 emoji (Optional[bool], optional): Enable emoji, or ``None`` to use Console default.
22 markup (Optional[bool], optional): Enable markup, or ``None`` to use Console default.
23 highlight (Optional[bool], optional): Enable highlighting, or ``None`` to use Console default.
24 highlighter (HighlighterType, optional): Optional highlighter to apply.
25 Returns:
26 ConsoleRenderable: Renderable object.
27
28 """
29 emoji_enabled = emoji or (emoji is None and self._emoji)
30 markup_enabled = markup or (markup is None and self._markup)
31 highlight_enabled = highlight or (highlight is None and self._highlight)
32
33 if markup_enabled:
34 rich_text = render_markup(
35 text,
36 style=style,
37 emoji=emoji_enabled,
38 emoji_variant=self._emoji_variant,
39 )
40 rich_text.justify = justify
41 rich_text.overflow = overflow
42 else:
43 rich_text = Text(
44 _emoji_replace(text, default_variant=self._emoji_variant)
45 if emoji_enabled
46 else text,
47 justify=justify,
48 overflow=overflow,
49 style=style,
50 )
51
52 _highlighter = (highlighter or self.highlighter) if highlight_enabled else None
53 if _highlighter is not None:
54 highlight_text = _highlighter(str(rich_text))
55 highlight_text.copy_styles(rich_text)
56 return highlight_text
57
58 return rich_text
Path 2: 219 calls (0.17)
'foo' (33) 'Step 0\nStep 1\nStep 2\nStep 3\nStep 4\nStep 5\nStep 6\nStep 7\nStep 8\nStep 9\n' (14) 'Step 0\n' (7) 'Step 0\nStep 1\n' (7) 'Step 0\nStep...
'' (201) 'rule.text' (18)
None (219)
None (219)
None (217) True (2)
None (217) True (2)
None (219)
None (123) ReprHighlighter (96)
Text (219)
1def render_str(
2 self,
3 text: str,
4 *,
5 style: Union[str, Style] = "",
6 justify: Optional[JustifyMethod] = None,
7 overflow: Optional[OverflowMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 highlighter: Optional[HighlighterType] = None,
12 ) -> "Text":
13 """Convert a string to a Text instance. This is called automatically if
14 you print or log a string.
15
16 Args:
17 text (str): Text to render.
18 style (Union[str, Style], optional): Style to apply to rendered text.
19 justify (str, optional): Justify method: "default", "left", "center", "full", or "right". Defaults to ``None``.
20 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to ``None``.
21 emoji (Optional[bool], optional): Enable emoji, or ``None`` to use Console default.
22 markup (Optional[bool], optional): Enable markup, or ``None`` to use Console default.
23 highlight (Optional[bool], optional): Enable highlighting, or ``None`` to use Console default.
24 highlighter (HighlighterType, optional): Optional highlighter to apply.
25 Returns:
26 ConsoleRenderable: Renderable object.
27
28 """
29 emoji_enabled = emoji or (emoji is None and self._emoji)
30 markup_enabled = markup or (markup is None and self._markup)
31 highlight_enabled = highlight or (highlight is None and self._highlight)
32
33 if markup_enabled:
34 rich_text = render_markup(
35 text,
36 style=style,
37 emoji=emoji_enabled,
38 emoji_variant=self._emoji_variant,
39 )
40 rich_text.justify = justify
41 rich_text.overflow = overflow
42 else:
43 rich_text = Text(
44 _emoji_replace(text, default_variant=self._emoji_variant)
45 if emoji_enabled
46 else text,
47 justify=justify,
48 overflow=overflow,
49 style=style,
50 )
51
52 _highlighter = (highlighter or self.highlighter) if highlight_enabled else None
53 if _highlighter is not None:
54 highlight_text = _highlighter(str(rich_text))
55 highlight_text.copy_styles(rich_text)
56 return highlight_text
57
58 return rich_text
Path 3: 1 calls (0.0)
'foo bar.foo bar.foo bar.foo bar.foo bar' (1)
'' (1)
None (1)
None (1)
False (1)
False (1)
None (1)
ReprHighlighter (1)
Text (1)
1def render_str(
2 self,
3 text: str,
4 *,
5 style: Union[str, Style] = "",
6 justify: Optional[JustifyMethod] = None,
7 overflow: Optional[OverflowMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 highlighter: Optional[HighlighterType] = None,
12 ) -> "Text":
13 """Convert a string to a Text instance. This is called automatically if
14 you print or log a string.
15
16 Args:
17 text (str): Text to render.
18 style (Union[str, Style], optional): Style to apply to rendered text.
19 justify (str, optional): Justify method: "default", "left", "center", "full", or "right". Defaults to ``None``.
20 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to ``None``.
21 emoji (Optional[bool], optional): Enable emoji, or ``None`` to use Console default.
22 markup (Optional[bool], optional): Enable markup, or ``None`` to use Console default.
23 highlight (Optional[bool], optional): Enable highlighting, or ``None`` to use Console default.
24 highlighter (HighlighterType, optional): Optional highlighter to apply.
25 Returns:
26 ConsoleRenderable: Renderable object.
27
28 """
29 emoji_enabled = emoji or (emoji is None and self._emoji)
30 markup_enabled = markup or (markup is None and self._markup)
31 highlight_enabled = highlight or (highlight is None and self._highlight)
32
33 if markup_enabled:
34 rich_text = render_markup(
35 text,
36 style=style,
37 emoji=emoji_enabled,
38 emoji_variant=self._emoji_variant,
39 )
40 rich_text.justify = justify
41 rich_text.overflow = overflow
42 else:
43 rich_text = Text(
44 _emoji_replace(text, default_variant=self._emoji_variant)
45 if emoji_enabled
46 else text,
47 justify=justify,
48 overflow=overflow,
49 style=style,
50 )
51
52 _highlighter = (highlighter or self.highlighter) if highlight_enabled else None
53 if _highlighter is not None:
54 highlight_text = _highlighter(str(rich_text))
55 highlight_text.copy_styles(rich_text)
56 return highlight_text
57
58 return rich_text
Path 4: 1 calls (0.0)
'[bold]foo[/bold]' (1)
'' (1)
None (1)
None (1)
None (1)
None (1)
None (1)
ReprHighlighter (1)
Text (1)
1def render_str(
2 self,
3 text: str,
4 *,
5 style: Union[str, Style] = "",
6 justify: Optional[JustifyMethod] = None,
7 overflow: Optional[OverflowMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 highlighter: Optional[HighlighterType] = None,
12 ) -> "Text":
13 """Convert a string to a Text instance. This is called automatically if
14 you print or log a string.
15
16 Args:
17 text (str): Text to render.
18 style (Union[str, Style], optional): Style to apply to rendered text.
19 justify (str, optional): Justify method: "default", "left", "center", "full", or "right". Defaults to ``None``.
20 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to ``None``.
21 emoji (Optional[bool], optional): Enable emoji, or ``None`` to use Console default.
22 markup (Optional[bool], optional): Enable markup, or ``None`` to use Console default.
23 highlight (Optional[bool], optional): Enable highlighting, or ``None`` to use Console default.
24 highlighter (HighlighterType, optional): Optional highlighter to apply.
25 Returns:
26 ConsoleRenderable: Renderable object.
27
28 """
29 emoji_enabled = emoji or (emoji is None and self._emoji)
30 markup_enabled = markup or (markup is None and self._markup)
31 highlight_enabled = highlight or (highlight is None and self._highlight)
32
33 if markup_enabled:
34 rich_text = render_markup(
35 text,
36 style=style,
37 emoji=emoji_enabled,
38 emoji_variant=self._emoji_variant,
39 )
40 rich_text.justify = justify
41 rich_text.overflow = overflow
42 else:
43 rich_text = Text(
44 _emoji_replace(text, default_variant=self._emoji_variant)
45 if emoji_enabled
46 else text,
47 justify=justify,
48 overflow=overflow,
49 style=style,
50 )
51
52 _highlighter = (highlighter or self.highlighter) if highlight_enabled else None
53 if _highlighter is not None:
54 highlight_text = _highlighter(str(rich_text))
55 highlight_text.copy_styles(rich_text)
56 return highlight_text
57
58 return rich_text