FIX: truncating a string fail when last space is within a tag

Patch for the truncate method because it doesn't work when the max is within a tag and the tag has space like img

see: https://github.com/joomla/joomla-cms/pull/978
Tracker ID http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=30552

I am sorry, I didn't got my fork in sync with the main repository so I had to delete some commits and unfortunately the code for the pull request got lost so I created a new pull request