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

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

am 24.02.2006 18:46:16 von metaperl

------=_Part_24271_5645199.1140803176043
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 2/24/06, Andy Armstrong wrote:
>
> I'm using HTML::Parser as part of a templating system that parses
> HTML formatted templates and interprets certain special tags. I'd
> like to be able to implement a tag like
>
>


If you want to stay pure HTML, then do this:



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.

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/

And you might like the CPAN module PeTaL or my own HTML::Seamstress

and XML::LibXML and XML::LibXSLT is XML floats your boat :)


To do that I'd like to subclass HTML::Parser and add an include()


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




--
http://slowchess.com/profile.php?username=3Dtbrannon http://www.moneycoop.o=
rg
http://www.osogd.org http://www.metaperl.com http://www.livingcosmos.org

------=_Part_24271_5645199.1140803176043--

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

am 24.02.2006 18:59:31 von Andy

On 24 Feb 2006, at 17:46, Terrence Brannon wrote:
> If you want to stay pure HTML, then do this:
>
>

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



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