Skip Menu |

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

Report information
The Basics
Id: 132797
Status: new
Priority: 0/
Queue: HTML-Tree

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

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



The "tighten" option upon instantiating a new HTML::TreeBuilder is not documented and is on by default. When dealing with templating and debugging them, it is important to get the html out as it was provided to HTML::TreeBuilder, otherwise html data without space or carriage returns makes it virtually impossible to review for humans. How to reproduce: Take some human readable html, i.e. with space and carriage returns, and feed it to HTML::TreeBuilder: my $tree = HTML::TreeBuilder->new(); $tree->parse( $html ); $tree->eof(); print( $tree->as_HTML() ); # All space, indent or cr/lf are now removed, making it unreadable Solution: Add pod documentation for "tighten" option. my $tree = HTML::TreeBuilder->new( tighten => 0, no_space_compacting => 1, ); $tree->parse( $$html ); $tree->eof(); print( $tree->as_HTML() ); # All space, indent or cr/lf are now removed, making it unreadable I don't think HTML::TreeBuilder should make assumptions that transform the way the original document was. If the user wants to tidy up and compress his/her html documents, there are modules dedicated to that. It is up to the user to make those calls.
On Wed Jun 10 02:49:23 2020, JDEGUEST wrote: Show quoted text
> The "tighten" option upon instantiating a new HTML::TreeBuilder is not > documented and is on by default. > When dealing with templating and debugging them, it is important to > get the html out as it was provided to HTML::TreeBuilder, otherwise > html data without space or carriage returns makes it virtually > impossible to review for humans. > > How to reproduce: > Take some human readable html, i.e. with space and carriage returns, > and feed it to HTML::TreeBuilder: > > my $tree = HTML::TreeBuilder->new(); > $tree->parse( $html ); > $tree->eof(); > print( $tree->as_HTML() ); # All space, indent or cr/lf are now > removed, making it unreadable > > Solution: > Add pod documentation for "tighten" option. > > my $tree = HTML::TreeBuilder->new( > tighten => 0, > no_space_compacting => 1, > ); > $tree->parse( $$html ); > $tree->eof(); > print( $tree->as_HTML() ); # All space, indent or cr/lf are now > removed, making it unreadable > > I don't think HTML::TreeBuilder should make assumptions that transform > the way the original document was. If the user wants to tidy up and > compress his/her html documents, there are modules dedicated to that. > It is up to the user to make those calls.
Typo: Of course, in the solution, the comment that the html is now unreadable should be discarded. Copy/paste...