Revision 536

Date:
2015/12/08 17:09:24
Author:
ahitrov
Revision Log:
During text_trim Encode::decode and Encode::encode operations are used before and after text manipulations

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/lib/Utils/HTML.pm

     
    247 247 # обрезает текст до нужной длины, предварительно удаляя html-теги (бывшая /inc/text_trim.msn)
    248 248 sub text_trim {
    249 249 my %opts = @_;
    250 my $text = $opts{'text'};
    250 my $text = Encode::decode('utf-8', $opts{'text'});
    251 251 my $length = $opts{'length'} || 200;
    252 my $ellipsis = $opts{'ellipsis'} || '…';
    252 my $ellipsis = Encode::decode('utf-8', $opts{'ellipsis'}) || '…';
    253 253 $text =~ s/<[^>]*>//g;
    254 254 if (length($text) > $length) {
    255 255 $text = substr($text, 0, $length);
    256 256 $text =~ s/\s+\S*$//;
    257 257 $text .= $ellipsis;
    258 258 }
    259 return $text;
    259 return Encode::encode('utf-8', $text);
    260 260 }
    261 261 # limit_words('text', { min_words => 70, max_words => 100, ending => '...' })
    262 262 sub limit_words {