def truncate(text, max_len=<NUM_LIT>, end='<STR_LIT>'):
if len(text) <= max_len:<EOL><INDENT>return text<EOL><DEDENT>return text[:max_len].rsplit('<STR_LIT:U+0020>', maxsplit=<NUM_LIT:1>)[<NUM_LIT:0>] + end<EOL>
Truncate the supplied text for display.

    Arguments:
      text (:py:class:`str`): The text to truncate.
      max_len (:py:class:`int`, optional): The maximum length of the
        text before truncation (defaults to 350 characters).
      end (:py:class:`str`, optional): The ending to use to show that
        the text was truncated (defaults to ``'...'``).

    Returns:
      :py:class:`str`: The truncated text.