Committer: vtroitsky
LJSUP-14218: Parser for Journalpromo works incorrectly for entries with <s>. It supposes that we have correct tags alignment U trunk/cgi-bin/LJ/Text.pm
Modified: trunk/cgi-bin/LJ/Text.pm =================================================================== --- trunk/cgi-bin/LJ/Text.pm 2012-11-13 15:44:45 UTC (rev 23298) +++ trunk/cgi-bin/LJ/Text.pm 2012-11-13 16:27:06 UTC (rev 23299) @@ -292,7 +292,6 @@ $str = $remove_last_word->($str); $remainder = substr($original_string, $class->byte_len($str)); - $str .= $ellipsis; } if ($chars && $class->char_len($str) > $chars) { @@ -328,12 +327,21 @@ $remainder = substr($original_string, $class->byte_len($str)); $str .= ' ' if($add_space && $str =~ /\S$/); - $str .= $ellipsis; + } elsif($force_ellipsis) { $str .= ' ' if($str =~ /\S$/); - $str .= $ellipsis; } - + + if($noparse_tags) { + while ( $_ = shift @$noparse_tags ) { + my $cnt = scalar($str =~ m/<$_>/g) || 0; + $cnt -= scalar($str =~ m/<$_\/>/g); + $str .= "<\/$_>" if ($cnt > 0); + } + } + + $str .= $ellipsis; + $str ||= $ellipsis if($fill_empty); $remainder =~ s/^\s+//;