euporie.core.widgets.dialog.to_formatted_text

euporie.core.widgets.dialog.to_formatted_text(value: AnyFormattedText, style: str = '', auto_convert: bool = False) FormattedText

Convert the given value (which can be formatted text) into a list of text fragments. (Which is the canonical form of formatted text.) The outcome is always a FormattedText instance, which is a list of (style, text) tuples.

It can take a plain text string, an HTML or ANSI object, anything that implements __pt_formatted_text__ or a callable that takes no arguments and returns one of those.

Parameters:
  • style – An additional style string which is applied to all text fragments.

  • auto_convert – If True, also accept other types, and convert them to a string first.