hgmnz/truncate_html — pull request #57 by AlexGunslinger (2014-11-01 20:19:34+00:00)
Title: Omission included when truncating by break_token.

This solves the issue #52

I just moved a little bit the logic to stop the truncation by break_token.

Instead of doing it on the truncate method (where it would not include the omission), I did it where the pipeline process occurs, if the token is the break token it will automatically put the chars_remaining at 0, and includes the omission if it happened.

I did it in a way that if the break token is a tag, it will include the omission anyway. If the tag is an opening tag, it will not include the tag, if it is a closing tag, it will include it via the close_open_tags method. (I guess that we don't want to leave any tag open in the string).

Doing it like this, we make sure that the truncation plus the omission will always be shorter or equal than the length param.

I included the proper test for this case.