Skip Menu |

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

Report information
The Basics
Id: 33063
Status: rejected
Priority: 0/
Queue: HTML-Tree

People
Owner: Nobody in particular
Requestors: grandpa [...] cpan.org
Cc:
AdminCc:

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



Subject: Feature request: suppress output of implicit elements by as_HTML
HTML::TreeBuilder has no trouble parsing HTML fragments, but HTML::Element's as_HTML method wraps the fragment in "implicit" elements(HTML, HEAD,BODY). It would be nice to (probably optionally) suppress generation of the implicit elements by as_HTML.
On Sun Feb 10 07:18:51 2008, GRANDPA wrote: Show quoted text
> HTML::TreeBuilder has no trouble parsing HTML fragments, but > HTML::Element's as_HTML method wraps the fragment in "implicit" > elements(HTML, HEAD,BODY). > It would be nice to (probably optionally) suppress generation of the > implicit elements by as_HTML.
Hi, I'm slowly working my way backward in time :) HTML::TreeBuilder adds the HTML, HEAD, and BODY tags when you run new, so these tags are always present when using TreeBuilder, and all the code is written with that assumption. It may be possible to hide these tags in the output, but since there are other implicit tags that people do generally want just ignoring implicit tags probably isn't good enough. You can work around this by finding the contents of the body node and printing it. I'll ahve a think about how to exclude just the implicit wrapper nodes and whether it should be done in just as_HTML or in all the as_** functions.. Cheers, Jeff.
On Sat, Feb 9, 2008 3:18:51 PM, GRANDPA wrote: Show quoted text
> HTML::TreeBuilder has no trouble parsing HTML fragments, but > HTML::Element's as_HTML method wraps the fragment in "implicit" > elements(HTML, HEAD,BODY). > It would be nice to (probably optionally) suppress generation of the > implicit elements by as_HTML.
Are you aware of the 'disembowel' method of HTML::TreeBuilder? It was intended just for this purpose of parsing document fragments. my @elements = HTML::TreeBuilder->new_from_file('fragment.html')->disembowel; @elements will be a list of the top-level HTML::Element nodes that appeared in fragment.html.