Awesome! Thank you Bill. It worked perfectly. Thanks again.
-----Original Message-----
From: moseley@hank.org [mailto:moseley@hank.org]
Sent: Thursday, July 31, 2003 4:29 PM
To: Multiple recipients of list
Subject: [SWISH-E] Re: swishdescription
On Wed, Jul 30, 2003 at 04:22:52PM -0700, Roubart Capcap wrote:
> Hi,
>
> On some of my PDF files, I have table contents. Since I use
> StoreDescription, part of the table of contents are stored as
> swishdescription shown below:
> Introduction...........................................................................................................
> i Disclaimer
> .............................................................................................................
> However, the length of it exceeds my HTML tables. Is there a way to
> set the wrapping length of the swishdescription? I am using the
> Template-Toolkit, so I was thinking of using the "remove" function to
> remove the "." but I can not seem to make it work. I would appreciate
> any help you can give. Thank you.
Can you use HTML or CSS to limit the width?
Anyway, here's how you can probably do it in the SWISH/TemplateToolkit
module:
Right below this line:
die $Template->error() unless $Template;
Try this:
$Template->context->define_filter(
'remove_repeat_chars',
sub {
my $text = shift;
$text =~ s/(.)\1{3,}/$1$1$1/g;
return $text;
}
);
That adds a new "Filter" into Template Toolkit. Then modify the output
of swishdescription to be:
[% item.swishdescription | remove_repeat_chars %]
Now, that matches any character that's repeated. If you only want to
match real dots then backslash the dot:
$text =~ s/(\.)\1{3,}/$1$1$1/g;
or better written:
$text =~ s/\.{4,}/.../g;
Post again if you want any of that explained more.
--
Bill Moseley
moseley@hank.org
Received on Fri Aug 1 17:00:50 2003