def cut_to_length(text, length, delim):
    """Shorten given text on first delimiter after given number
    of characters.
    """
    cut = text.find(delim, length)
    if cut > -1:
        return text[:cut]
    else:
        return text