Convert a string to a Text instance. This is called automatically if you print or log a string. Args: text (str): Text to render. style (Union[str, Style], optional): Style to apply to rendered text. justify (str, optional): Justify method: "defau
(
self,
text: str,
*,
style: Union[str, Style] = "",
justify: Optional[JustifyMethod] = None,
overflow: Optional[OverflowMethod] = None,
emoji: Optional[bool] = None,
markup: Optional[bool] = None,
highlight: Optional[bool] = None,
highlighter: Optional[HighlighterType] = None,
)
| 1407 | return lines |
| 1408 | |
| 1409 | def render_str( |
| 1410 | self, |
| 1411 | text: str, |
| 1412 | *, |
| 1413 | style: Union[str, Style] = "", |
| 1414 | justify: Optional[JustifyMethod] = None, |
| 1415 | overflow: Optional[OverflowMethod] = None, |
| 1416 | emoji: Optional[bool] = None, |
| 1417 | markup: Optional[bool] = None, |
| 1418 | highlight: Optional[bool] = None, |
| 1419 | highlighter: Optional[HighlighterType] = None, |
| 1420 | ) -> "Text": |
| 1421 | """Convert a string to a Text instance. This is called automatically if |
| 1422 | you print or log a string. |
| 1423 | |
| 1424 | Args: |
| 1425 | text (str): Text to render. |
| 1426 | style (Union[str, Style], optional): Style to apply to rendered text. |
| 1427 | justify (str, optional): Justify method: "default", "left", "center", "full", or "right". Defaults to ``None``. |
| 1428 | overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to ``None``. |
| 1429 | emoji (Optional[bool], optional): Enable emoji, or ``None`` to use Console default. |
| 1430 | markup (Optional[bool], optional): Enable markup, or ``None`` to use Console default. |
| 1431 | highlight (Optional[bool], optional): Enable highlighting, or ``None`` to use Console default. |
| 1432 | highlighter (HighlighterType, optional): Optional highlighter to apply. |
| 1433 | Returns: |
| 1434 | ConsoleRenderable: Renderable object. |
| 1435 | |
| 1436 | """ |
| 1437 | emoji_enabled = emoji or (emoji is None and self._emoji) |
| 1438 | markup_enabled = markup or (markup is None and self._markup) |
| 1439 | highlight_enabled = highlight or (highlight is None and self._highlight) |
| 1440 | |
| 1441 | if markup_enabled: |
| 1442 | rich_text = render_markup( |
| 1443 | text, |
| 1444 | style=style, |
| 1445 | emoji=emoji_enabled, |
| 1446 | emoji_variant=self._emoji_variant, |
| 1447 | ) |
| 1448 | rich_text.justify = justify |
| 1449 | rich_text.overflow = overflow |
| 1450 | else: |
| 1451 | rich_text = Text( |
| 1452 | ( |
| 1453 | _emoji_replace(text, default_variant=self._emoji_variant) |
| 1454 | if emoji_enabled |
| 1455 | else text |
| 1456 | ), |
| 1457 | justify=justify, |
| 1458 | overflow=overflow, |
| 1459 | style=style, |
| 1460 | ) |
| 1461 | |
| 1462 | _highlighter = (highlighter or self.highlighter) if highlight_enabled else None |
| 1463 | if _highlighter is not None: |
| 1464 | highlight_text = _highlighter(str(rich_text)) |
| 1465 | highlight_text.copy_styles(rich_text) |
| 1466 | return highlight_text |
no test coverage detected