- if len(parts) == 1 or len(parts[0]) > 200:
- p1 = description[:200].rsplit(' ', 1)[0]
- p2 = description[len(p1):]
- p1 += '…'
- p2 = '…' + p2
+ if len(parts) == 1 or len(parts[0]) > 240:
+ # No newline found here.
+ # Try to find last sentence end..
+ parts = re.split(r' \.', description[240::-1], 1)
+ if len(parts) == 2:
+ p1 = parts[1][::-1] + '.'
+ p2 = description[len(p1) + 1:]
+ else:
+ # No sentence end found.
+ # Just find a space.
+ p1 = description[:240].rsplit(' ', 1)[0]
+ p2 = description[len(p1) + 1:]
+ p1 += '…'
+ p2 = '…' + p2