Re: Subclassing HTML::Parser to support $p->include()

Andy Armstrong <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On 24 Feb 2006, at 17:46, Terrence Brannon wrote:
> If you want to stay pure HTML, then do this:
>
> <span myparser_action="include" myparser_args="header.html" />

The syntax was just chosen for conciseness but the actual syntax  
looks like

<ido:include src="blah.html" />

I /assumed/ (perhaps mistakenly) that HTML::Parser would be OK with  
arbitrary tag names provided everything was syntactically correct. Is  
that a stupid assumption?

> No need to use non-HTML and expect an HTML parser to parse it. If  
> you want
> non-HTML, then maybe XML parsing is more appropriate.

That's certainly a possibility - although a quick glance at  
XML::Parser suggests that I'd have at least the same - and possibly  
worse - problems implementing an include() method on it.

> Also, what you want appears to be do-able using the formerCPAN module
> HTML_Tree by Paul J Lucas:
> http://homepage.mac.com/pauljlucas/software/html_tree/

OK, that may be an option - although I have a working template  
compiler built around HTML::Parser already so I'd rather keep going  
in that direction unless it's a dead end :)

> And you might like the CPAN module PeTaL or my own HTML::Seamstress
>
> and XML::LibXML and XML::LibXSLT is XML floats your boat :)

OK :)

> why not use HTML::Tree on CPAN (HTML::Tree is on CPAN, HTML_Tree is  
> at the
> URL I gave you previously).

Build parse trees and then merge them? I could do - altenately I  
could introduce a preprocessor stage using HTML::Parser that expanded  
the include tags and generated HTML source with the included chunks  
included and then parse that a second time. Ideally though I'd like  
to handle the include directive at the same stage where I handle my  
other tags - for various architectural reasons I won't bore you with.

Thanks :)

-- 
Andy Armstrong, hexten.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.