Omission included when truncating by break_token.#57
Open
AlexGunslinger wants to merge 2 commits intohgmnz:masterfrom
Open
Omission included when truncating by break_token.#57AlexGunslinger wants to merge 2 commits intohgmnz:masterfrom
AlexGunslinger wants to merge 2 commits intohgmnz:masterfrom
Conversation
There was a problem hiding this comment.
You haven't specified an omission here. You've already tested that the default omission of ... works with all the other tests. You should probably do something like:
truncate('This is the time to truncate this. Do it properly!', :length => 50, :break_token => 'truncate', :omission => link_to(' MORE', 'path')).should == 'This is the time to <a href="path">MORE</a>'
Author
There was a problem hiding this comment.
Thanks @gwagener! It was a good idea to include a test with a custom omission.
delxen
pushed a commit
to skroutz/truncate_html
that referenced
this pull request
Apr 18, 2019
When using break_token, omissions was not added in the truncated html. Fix based on hgmnz/truncate_html#57. Issue described here hgmnz/truncate_html#52
delxen
pushed a commit
to skroutz/truncate_html
that referenced
this pull request
Apr 18, 2019
When using break_token, omissions was not added in the truncated html. Fix based on hgmnz/truncate_html#57. Issue described here hgmnz/truncate_html#52
delxen
pushed a commit
to skroutz/truncate_html
that referenced
this pull request
Apr 18, 2019
When using break_token, omissions was not added in the truncated html. Fix based on hgmnz/truncate_html#57. Issue described here hgmnz/truncate_html#52
delxen
pushed a commit
to skroutz/truncate_html
that referenced
this pull request
Apr 19, 2019
When using break_token, omissions was not added in the truncated html. Fix based on hgmnz/truncate_html#57. Issue described here hgmnz/truncate_html#52
delxen
pushed a commit
to skroutz/truncate_html
that referenced
this pull request
Apr 22, 2019
When using break_token, omissions was not added in the truncated html. Fix based on hgmnz/truncate_html#57. Issue described here hgmnz/truncate_html#52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.