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