MCPcopy
hub / github.com/Textualize/rich / from_markup

Method from_markup

rich/text.py:260–291  ·  rich/text.py::Text.from_markup

Create Text instance from markup. Args: text (str): A string containing console markup. style (Union[str, Style], optional): Base style for text. Defaults to "". emoji (bool, optional): Also render emoji code. Defaults to True. emoji_variant (

(
        cls,
        text: str,
        *,
        style: Union[str, Style] = "",
        emoji: bool = True,
        emoji_variant: Optional[EmojiVariant] = None,
        justify: Optional["JustifyMethod"] = None,
        overflow: Optional["OverflowMethod"] = None,
        end: str = "\n",
    )

Source from the content-addressed store, hash-verified

258
259 @classmethod
260 def from_markup(
261 cls,
262 text: str,
263 *,
264 style: Union[str, Style] = class="st">"",
265 emoji: bool = True,
266 emoji_variant: Optional[EmojiVariant] = None,
267 justify: Optional[class="st">"JustifyMethod"] = None,
268 overflow: Optional[class="st">"OverflowMethod"] = None,
269 end: str = class="st">"\n",
270 ) -> class="st">"Text":
271 class="st">"""Create Text instance from markup.
272
273 Args:
274 text (str): A string containing console markup.
275 style (Union[str, Style], optional): Base style for text. Defaults to class="st">"".
276 emoji (bool, optional): Also render emoji code. Defaults to True.
277 emoji_variant (str, optional): Optional emoji variant, either class="st">"text" or class="st">"emoji". Defaults to None.
278 justify (str, optional): Justify method: class="st">"left", class="st">"center", class="st">"full", class="st">"right". Defaults to None.
279 overflow (str, optional): Overflow method: class="st">"crop", class="st">"fold", class="st">"ellipsis". Defaults to None.
280 end (str, optional): Character to end text with. Defaults to class="st">"\\\\n".
281
282 Returns:
283 Text: A Text instance with markup rendered.
284 class="st">"""
285 from .markup import render
286
287 rendered_text = render(text, style, emoji=emoji, emoji_variant=emoji_variant)
288 rendered_text.justify = justify
289 rendered_text.overflow = overflow
290 rendered_text.end = end
291 return rendered_text
292
293 @classmethod
294 def from_ansi(

Callers 15

test_from_markupFunction · 0.80
test_endFunction · 0.80
test_split_spansFunction · 0.80
test_renderFunction · 0.80
test_get_style_at_offsetFunction · 0.80
test_sliceFunction · 0.80
test_markup_propertyFunction · 0.80
test_extend_styleFunction · 0.80
test_divide_complexFunction · 0.80
table_movie.pyFile · 0.80

Calls 1

renderFunction · 0.90

Tested by 11

test_from_markupFunction · 0.64
test_endFunction · 0.64
test_split_spansFunction · 0.64
test_renderFunction · 0.64
test_get_style_at_offsetFunction · 0.64
test_sliceFunction · 0.64
test_markup_propertyFunction · 0.64
test_extend_styleFunction · 0.64
test_divide_complexFunction · 0.64