not working when text is html
seems like there is a problem when the text string contains HTML.
Hi michaelmel, what is exactly the problem you found? Do you refer to html tags not being displayed as plain text?
For some reason, when I tried to use it, HTML got converted into plain text. I could see the HTML code, but it was not rendering as such. Maybe I was doing something wrong?
Absolutely michaelmel. Actually, sorry for my typo in the previous message. Where I wrote "Do you refer to html tags not being displayed as plain text?" I actually meant "Do you refer to html tags being displayed as plain text?".
Well, the original goals of this directive didn't include display HTML text as plain text. Do you mind explain what is your use case for truncating text displaying HTML as plain text? I have to think a little bit about how to include this behavior in the directive...
In my case I display a snipped which contains some basic html tags (like text formatting: b, i, u). Ideally it would be nice know that html is not cut in the middle of the tag. I know it's a lot to ask, and I don't expect it to work perfectly, as the task of making sure there is no problems with html is in app developer's hands.
Depending on where the text is coming from, like user provided text that you don't have control of, allowing this to accept/render html tags is potentially allowing XSS attacks on your application, just something to be aware of in case your using this for user content you could get a string from a user like:
"Some filler >script>alert("XSS")>/script> text."
Hi, I'm having some trouble if the text is html format. For example, the text is:
This is short text.This is more text
then, the ng-text-truncate generate this code:
This is short text....<span class='btn-link ngTruncateToggleText' ng-click='toggleShow()'ng-show='!open'> Show
which is not properly html enclosed. see the matching of
tag.
Both the more and less link will appears when page loads.
Could you give suggestion how to fix this issue?
Thanks!
@lorenooliveira I have the same issue as @sh977218
Screenshot -

Hoping for a quick fix on this one.
same issue here, also if the last charset is a break line you get ; and if you use ng-text-truncate="longtext | linky:'_blank'" and the link is exactly in the limit of characters you get that strange behavior
$scope.longText = $scope.longText.replace('
', '').replace('
',);