The stupid question is the question not asked | |
PerlMonks |
Re: Truncating HTML earlyby Anonymous Monk |
on Mar 17, 2002 at 20:28 UTC ( [id://152347]=note: print w/replies, xml ) | Need Help?? |
Slash (the code that runs Slashdot) has to do this often. For display in the main comment list, we truncate users' comments that exceed a certain length, and then have to close up all the tags and such.
This is done near the top of the dispComment() function, in Slash.pm. Basically, we call chopEntity() which truncates to a given size without interrupting an HTML entity; strip_html() which takes out any illegal HTML tags; then balanceTags() which rebalances everything. Those are all in Slash::Utility::Data. You can ignore the </A> fixing and addDomainTags() since you won't be using that of course. - Jamie
In Section
Seekers of Perl Wisdom
|
|