collective / collective.sidebar

A sidebar for Plone to consolidate toolbar and navigation
GNU General Public License v2.0
6 stars 4 forks source link

Refactor utils.py - crop() #65

Closed sarn0ld closed 5 years ago

sarn0ld commented 5 years ago

While writing tests i found some strange behaviour in the crop()-function in utils.py. Not sure what was intended for this to do exactly. However this needs refactoring. See test_crop() for further information!

Netroxen commented 5 years ago

The method is supposed to crop text using word boundaries, not actual character limits. So if a word exceeds the character limit then the method will remove the word and replace it with ....

This just looks a little cleaner than abruptly cropping the sentence mid-word. We can add a boolean param that allows text to be cropped on an actual character limit though...

sarn0ld commented 5 years ago

Thank you for the information! Then I wouldn't add the cropping on actual char limit, but do these fixes, so that my test_crop method is green:

sarn0ld commented 5 years ago

I opened a PR as suggestion