You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to suggest to have the option to count the length of HTML tags in maxLength. I need an email template that can't exceed 255 chars but if template.length - tagsInTemplate.length < 255 than the clipper will return my original template which is longer than 255 with the tags.
The text was updated successfully, but these errors were encountered:
This is an interesting request. Almost all logic in text-clipper is aimed towards counting characters and lines, which you don't need if you care more about the template size than the actual character count.
I also suspect there is another important difference there: I suspect your maximum template length would be a byte-count, or maybe a count of UTF16 codepoints, whereas text-clipper counts Unicode characters in order to prevent breaking up Unicode surrogate pairs (note this can still break up compound emojis into the individual emoji characters, but at least individual emojis won't be broken up into invalid Unicode characters).
All that logic isn't relevant when you care primarily about raw length of the HTML, it seems the only logic that you would be interested in is finding a suitable position for breaking up the HTML string. I suppose a solution like that could be created using some of the logic inside text-clipper, but for me personally it's too far out of scope to implement myself.
If someone would create a PR that implements this suggestion, without harming the performance and complexity of the already existing clippers, I'd be willing to accept that. But that probably means implementing a separate (simpler) clipRawHtml() function next to the already existing clipHtml() implementation.
I'd like to suggest to have the option to count the length of HTML tags in maxLength. I need an email template that can't exceed 255 chars but if
template.length
-tagsInTemplate.length
< 255 than the clipper will return my original template which is longer than 255 with the tags.The text was updated successfully, but these errors were encountered: