Skip Menu |

This queue is for tickets about the HTML-SyntaxHighlighter CPAN distribution.

Report information
The Basics
Id: 1725
Status: resolved
Priority: 0/
Queue: HTML-SyntaxHighlighter

People
Owner: Nobody in particular
Requestors: rons [...] deakin.edu.au
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Module fails to call end_document() after new(out_func...)
Re: HTML-SyntaxHighlighter-0.01.tgz: I'm using my($parser)= HTML::SyntaxHighlighter -> new(out_func => \$var); $parser -> parse($content); I found I had to call $parser -> end_document(); in order to get the </code> token emitted. I think this should be called automatically at the end of parse, at least when output is redirected to a variable.
[guest - Sun Oct 27 18:58:08 2002]: Show quoted text
> I found I had to call > $parser -> end_document(); > in order to get the </code> token emitted. I think this should be > called automatically at the end of parse, at least when output is > redirected to a variable.
This is a deliberate feature of HTML::Parser (which HTML::SyntaxHighlighter inherits); it allows you to separate a html document into chunks and parse it a bit at a time. You are meant to call $parser->eof() when you've reached the end of the document. Apologies for the tardiness of my reply, my PAUSE email was being delivered to the wrong mailbox :/ -- Alex
[rons@deakin.edu.au - Wed Dec 18 19:03:17 2002]: Show quoted text
> On Wed, 18 Dec 2002 14:12:31 -0500 (EST), via RT wrote: > OK. I didn't understand that.
Maybe this is easier to demonstrate than explain. The fact that $p->parse _doesn't_ call end_document() allows you to do things like this: #!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTML::SyntaxHighlighter; my $ua = LWP::UserAgent->new; my $sh = HTML::SyntaxHighlighter->new; my $url = 'http://www.perlmonks.org/'; my $res = $ua->request( HTTP::Request->new(GET => $url), sub { my($chunk, $res) = @_; $sh->parse( $chunk ); } ); $sh->eof;