vaakash / jquery-collapser

jQuery collapser is a small and useful jQuery plugin for collapsing/truncating an element text by words, characters and lines with a flexible API. It is an all in one plugin with multiple functionalities to truncate a paragraph or any element as desired.
MIT License
99 stars 35 forks source link

Prevent stripping html when no truncation is needed? #5

Open suture opened 9 years ago

suture commented 9 years ago

Is it possible to prevent stripping html when no truncation is needed?

For example if truncation kicks in at 5 lines, but you only have 4, in this scenario, it becomes impossible to see the html version.

vaakash commented 9 years ago

Hi Suture, during the collapse HTML is stripped because there are cases where there can be images,videos,list and other block level items with each having separate CSS properties and different margin and padding. So collpasing the element to a particular line is quite challenging and may not work in all sites with different base CSS. Since collpaser also suports collpasing to particular characters this scenario also has to be handled gracefully.

This feature can be implemented but not on by default. Should be enabled on demand through an additional property. I'll try to work on this.

suture commented 9 years ago

Hi Vaakash

Yes understand. Many thanks for getting back to me.

notcmoore commented 9 years ago

I too would like to have this feature. When I have a ul/ol list, the bullets/numbers are removed, so the truncated block looks like a giant mess of an incomplete sentence.

Thanks.

valentinbrandt commented 9 years ago

+1 This could be very very useful.

bcrigler commented 8 years ago

Why not just strip image, video, and media tags and nothing else? There should be a property for "allowed tags" and could be used at the risk of the User.

suture commented 8 years ago

In Wordpress I use this plugin Advanced Excerpt https://wordpress.org/plugins/advanced-excerpt/ which allows you to choose which tags get stripped. It somehow manages to prevent any issues with truncated closing tags.

vaakash commented 8 years ago

@suture Let me check that for a reference try to implement the same. @bcrigler The problem which I got during testing is, when the "divs", "span" tags in collapsible element had a different a padding, margin then it was odd for the collpase animation. I'll anyway try to implement the same as many request it.