diff --git a/lib/Template/Filters.pm b/lib/Template/Filters.pm index dd52bcc5..aa0229bf 100644 --- a/lib/Template/Filters.pm +++ b/lib/Template/Filters.pm @@ -521,8 +521,16 @@ sub truncate_filter_factory { $len = $TRUNCATE_LENGTH unless defined $len; $char = $TRUNCATE_ADDON unless defined $char; - # Length of char is the minimum length my $lchar = length $char; + my $extra = $char; + my $CER = '[:#_A-Za-z][:A-Za-z0-9\-\_]+'; + + if ($char =~ /\&($CER;)/) { + $extra =~ s,\&($CER;),_,g; + $lchar = length $extra; + } + + # Length of char is the minimum length if ($len < $lchar) { $char = substr($char, 0, $len); $lchar = $len; diff --git a/lib/Template/Manual/Filters.pod b/lib/Template/Manual/Filters.pod index 6c9fb571..802755ab 100644 --- a/lib/Template/Manual/Filters.pod +++ b/lib/Template/Manual/Filters.pod @@ -326,7 +326,7 @@ second argument. Output: - I have much to say… + I have much to say on this… =head1 repeat(iterations) diff --git a/t/filter.t b/t/filter.t index 1e8f17bb..5e784731 100644 --- a/t/filter.t +++ b/t/filter.t @@ -975,3 +975,16 @@ foo(bar) [% "foo(bar)" | uri %] -- expect -- foo(bar) + +-- test -- +[% "I have much to say on this matter that has previously + been said on more than one occasion." | truncate(27,"…") %] +-- expect -- +I have much to say on this… + +-- test -- +[% "I have much to say on this matter that has previously + been said on more than one occasion." | truncate(27,"…") %] +-- expect -- +I have much to say on this… +