code: def shorted(text, width=79):
      
      if len(text) <= width:
          return text
      # We remove any word after first overlapping non-word character
      return u"{0}...".format(re.sub(r"\W+\w*$", "", text[:width - 2]))
docs: Shorten text, make sure it's not cut in the middle of a word