def set_linebreaks(desc: str) ->str:
    """
    Sets newlines after max 45 characters (or the latest space to avoid non-sense separation)
    :param desc: The parsed long description for the sepcific template
    :return: The formatted string with inserted newlines
    """
    linebreak_limit = 50
    last_space = -1
    cnt = 0
    idx = 0
    while idx < len(desc):
        if cnt == linebreak_limit:
            desc = desc[:last_space] + '\n' + desc[last_space + 1:]
            cnt = 0
        elif desc[idx] == ' ':
            last_space = idx
        cnt += 1
        idx += 1
    return desc
