Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: completely rewind an HTML::TokeParser (PullParser): msg#00052

lang.perl.modules.lwp

Subject: Re: completely rewind an HTML::TokeParser (PullParser)

D'oh, sorry, just realized that proposed sub change is useless. So, please ignore that part. Still looking for ideas to make the rewind work though.

On Wednesday, December 21, 2005, at 11:23 AM, Ashley Pond V wrote:

I want to parse out some HTML to count the text characters and then rewind to the beginning of the parser to step through tags and excerpt to an argument supplied character or percentage point in the *text* chars and then, keeping track of what tags are open, automatically add close tags.

To be used in a TT2 filter like "truncate" but for HTML instead of plain text. So that...

[% html = "<p><b>this <i>is something to truncate</i></b></p>" %]
[% html | truncate_html(10) %]

Would output
<p><b>this <i>is so...</i></b></p>
^^^^^^12345^^^67890

Anyway, the trouble I'm trying to address is rewinding the parser for the second walkthrough once I've counted text characters.

I want to do this: 1 while $p->unget_token()

But it doesn't work because HTML::PullParser->unget_token returns the parser object itself.

To make a long story short, and it's not too late for that -- would changing the return be reasonable or would it break code?

sub unget_token
{
my $self = shift;
unshift @{$self->{pullparser_accum}}, @_;
# $self; <-- change, don't return $self anymore
}

If not, does anyone have a smart idea for how to rewind it while respecting the interface (ie, not testing $self->{pullparser_accum})?

Thanks!
-Ashley





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    gcc.libstdc++.c...    solaris.opensol...    information-ret...    misc.misterhous...    web.catalyst.ge...    apache.webservi...    redhat.release....    hardware.lirc/2...    kernel.autofs/2...    technology.sust...    linux.vdr/2003-...    editors.lyx.gen...    org.user-groups...    netbsd.devel.pk...    xdg.devel/2004-...    version-control...    jakarta.slide.d...    debian.packages...    creativecommons...    ports.ppc.embed...    bug-tracking.bu...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe