ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r17391: LJSUP-6110, LJSUP-6803 - keep html entit...

Committer: ssafronova
LJSUP-6110, LJSUP-6803 - keep html entity whole when trimming text
U   trunk/cgi-bin/ljtextutil.pl
Modified: trunk/cgi-bin/ljtextutil.pl
===================================================================
--- trunk/cgi-bin/ljtextutil.pl	2010-09-16 08:00:02 UTC (rev 17390)
+++ trunk/cgi-bin/ljtextutil.pl	2010-09-16 08:14:11 UTC (rev 17391)
@@ -463,6 +463,14 @@
             my $max = (sort {$b cmp $a} $space_idx, $dot_idx, $comma_idx, $semi_idx, $colon_idx)[0];
             $short_text = substr($text, 0, $max);
 
+            # attention: ࡄ must not lose ';' sign
+            if ($max == $semi_idx) {
+                my $one_char_longer = substr($text, 0, $max + 1);
+                if ($one_char_longer =~ /&.+;$/) { # entity in any form
+                    $short_text = $one_char_longer; # we must keep in whole
+                }
+            }
+
             # seconde attempt to reduce text to the end of phrase
             return $short_text . '...' if $short_text =~ s/([.;:!?])[^\\1]{1,5}$//;
         }

Tags: livejournal, pl, ssafronova
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments