Html tags problem in truncated text

I have problem with truncation of text. My text includes html tags also.
On main page I display only 100 characters of it, and give read more
link to user. Now if within these 100 characters, if there is any html
tag that is opening and not getting closed within 100 characters, then
that html tag is getting displayed on main page.

How can I solve this problem? Is there any solution for it?

On Tue, Jul 29, 2008 at 8:43 AM, Sunny B.
[email protected] wrote:

I have problem with truncation of text. My text includes html tags also.
On main page I display only 100 characters of it, and give read more
link to user. Now if within these 100 characters, if there is any html
tag that is opening and not getting closed within 100 characters, then
that html tag is getting displayed on main page.

How can I solve this problem? Is there any solution for it?

Call strip_tags before truncating

See:
http://api.rubyonrails.com/classes/ActionView/Helpers/SanitizeHelper.html#M001620

I’m following this topic merely because I’m interested in the outcome.
I looked up strip_tags in the API and it seems that it ‘removes’ the
tags. I don’t believe that’s what Sunny wants. Truncate take a number
of characters and appends a … removing the remaining characters that
may have been there. If the end tag of a is truncated away, then
all the text from that point on will be bolded. How is this resolved?

~Dustin T.