File: html2xhtml

package info (click to toggle)
libhtml-html5-parser-perl 0.992-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,444 kB
  • sloc: perl: 16,129; makefile: 2; sh: 1
file content (24 lines) | stat: -rw-r--r-- 417 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
## skip Test::Tabs

use 5.010;
use HTML::HTML5::Parser;

my $input  = shift // '-';
my $output = shift // '-';

my $parser = HTML::HTML5::Parser->new;
my $dom = ($input eq '-')
	? $parser->parse_string(do { local $/ = <STDIN> })
	: $parser->parse_file($input);

if ($output eq '-')
{
	print $dom->toString;
}
else
{
	open my($fh), '>:encoding(UTF-8)', $output;
	print $fh $dom->toString;
	close $fh;
}