When using HTML :: Tidy on Windows to clear the output of the HTML :: Element as_HTML method, I get the wrong newline type. If I do not specify a new line in the HTML :: Tidy constructor, I get my lines terminated by CRCRLF. If I specify the ending of LF, I get "CRLF", and if I specify "CRLF", I get the initial completion of CRCRLF. I suspect that this is a bug in the HTMLtidy library, and it can be easily circumvented by explicitly indicating the end of Unix, and get a DOS that almost any worthy editor can analyze on any platform.
In response, I solved the problem using binmode ': raw: utf8' in the appropriate descriptor to disable interpolation /n :
my $output = IO::File->new($ARGV[1], 'w'); $output->binmode(':raw:utf8'); print $output HTML::Tidy->new( { wrap => 80, indent => 'auto', 'wrap-attributes' => 'yes', } )->clean($tree->as_HTML());
This is pretty general, but I canβt find a real mention of other issues besides a common error in the HTMLtidy library. Has anyone dealt with this problem and can confirm that this is a library error? I would be surprised if so, because the library has been for centuries and wants to confirm before submitting a report.
Edit: I updated the code to show the creation of the file descriptor. The problem can be solved by setting the filehandle binmode to raw, but then I have problems due to Unicode in the HTML content. Is there any way to resolve it without inserting other problems?
Edit 2: I should notice that I initially saw this as an HTML :: Tidy problem, because when printing the direct $ tree-> as_HTML (), the correct EOL characters were given to the file descriptor with any binmode method. The problem only appeared after I completed the scalar output of HTML :: Element as HTML code with HTML :: Tidy.
Oesor source share