Hi,
I have a variable which contains some HTML text which may contain some tags,
like or and I'd like to truncate it. The problem is that
truncate doesn't preserve the HTML tags, so this can break my page, like in
this example:
$foo = "blablablabla f"
in my template:
[% FILTER truncate(10
greetings,
I use something similar to filter the HTML altogether. Just for that
purpose.
MACRO escape( text )
BLOCK;
GET text.replace('<(/?)([biau])>', '').replace('',
'');
END;
But I only allow bold, italic, underline, and links, to be there in the
first place.
It's used like so:
[% escape(
Along w/ the problem of unbalancing tags there is also the white space
issue (e.g. you want 100 characters you could have 'a' .
$ninety_five_spaces . 'b' . $tons_of_text. and the truncated verbiage
is essencially 'a b'
length of character entities (e.g < == 1 character not 4)
Fortunately it
On Apr 10, 2009, at 10:58 AM, Lee.M wrote:
> Along w/ the problem of unbalancing tags there is also the white space
> issue (e.g. you want 100 characters you could have 'a' .
> $ninety_five_spaces . 'b' . $tons_of_text. and the truncated verbiage
> is essencially 'a b'
>
> length of character ent
Lee.M wrote:
> On Apr 10, 2009, at 10:58 AM, Lee.M wrote:
>
>> Along w/ the problem of unbalancing tags there is also the white space
>> issue (e.g. you want 100 characters you could have 'a' .
>> $ninety_five_spaces . 'b' . $tons_of_text. and the truncated verbiage
>> is essencially 'a b'
>>
>> l
On Apr 10, 2009, at 3:22 PM, Josh Rosenbaum wrote:
> Lee.M wrote:
>> On Apr 10, 2009, at 10:58 AM, Lee.M wrote:
>>> Along w/ the problem of unbalancing tags there is also the white
>>> space
>>> issue (e.g. you want 100 characters you could have 'a' .
>>> $ninety_five_spaces . 'b' . $tons_of_te
WOW!
Now I feel real silly. (Usually results in good things)
I'm going to ease everything over to HTML::Truncate now, I believe...
It never ceases to amaze me how often I try to re invent the wheel.
(unknowingly)
Note to self: "Before attempting ANY new project, search CPAN!!!"
Thanks!
:)
O
Lee.M wrote:
>> HTML::Parser can usually handle improper HTML better at the expense
>> of speed.
>
> I think it uses HTML::Truncate under the hood
I think you meant HTML::Truncate uses HTML::Parser under the hood. :P (I
checked and that appears to be true.) HTML::Parser is awesome. I've used i