-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
We have noticed that Truncato does not truncate so the final string results in max length, but rather max length calculates on the original string. This means the final result is affected by the quality of the markup. This can be seen with two content blocks that are identical in content, but different in markup.
Truncato
str1 = "Hello, How is the weather"
str2 = "Hello, <div style=\"color: #green,background-color:#yellow;overflow:auto\">How is the weather"
[36] pry(main)> Truncato.truncate(str1, max_length: 22)
=> "Hello, How is the weat..."
[37] pry(main)> Truncato.truncate(str2, max_length: 22)
=> "Hello, <div style='color: #green,background-color:#yellow;overflow:auto'>...</div>"For addititional reference, there is a js function that truncates and preserves markup and results in this behavior of resulting in a string of a desired content length (without markup).
str1 = "Hello, How is the weather"
str2 = "Hello, <div style=\"color: #green,background-color:#yellow;overflow:auto\">How is the weather"
truncate(str1, 22)
'Hello, How is the weat...'
truncate(str2, 22)
'Hello, <div style="color: #green,background-color:#yellow;overflow:auto">How is the weat...</div>'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels