def METHOD_NAME(s: str, maxlen: int = 128, suffix: str = '...') -> str:
    """Truncate text to a maximum number of characters."""
    if maxlen and len(s) >= maxlen:
        return s[:maxlen].rsplit(' ', 1)[0] + suffix
    return s