HTML::TruncateHTML::Truncate is a Perl module that can truncate HTML by percentage or character count while preserving well-formedness. | |
Download |
HTML::Truncate Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Ashley Pond V
- Publisher web site:
- http://search.cpan.org/~ashley/Lingua-EN-Titlecase-0.06/lib/Lingua/EN/Titlecase.pm
HTML::Truncate Tags
HTML::Truncate Description
HTML::Truncate is a Perl module that can truncate HTML by percentage or character count while preserving well-formedness. HTML::Truncate is a Perl module (beta software) that can truncate HTML by percentage or character count while preserving well-formedness.ABSTRACTWhen working with text it is convenient and common to want to truncate strings to make them fit a desired context. E.g., you might have a menu that is only 100px wide and prefer text doesn't wrap so you'd truncate it around 15-30 characters, depending on preference and typeface size. This is trivial with plain text using substr but with HTML it is somewhat difficult because whitespace has fluid significance and open tags that are not properly closed destroy well-formedness and can wreck an entire layout.HTML::Truncate attempts to account for those two problems by padding truncation for spacing and entities and closing any tags that remain open at the point of truncation.SYNOPSIS use strict; use HTML::Truncate; my $html = 'We have to test something.'; my $readmore = '... '; my $html_truncate = HTML::Truncate->new(); $html_truncate->chars(20); $html_truncate->ellipsis($readmore); print $html_truncate->truncate($html), $/; # or my $ht = HTML::Truncate->new(utf => 1, chars => 1_000, ); print $ht->truncate($html), $/; Requirements: · Perl
HTML::Truncate Related Software