/usr/bin/html5debug is in libhtml-html5-parser-perl 0.301-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #!/usr/bin/perl
## skip Test::Tabs
use Getopt::Long;
use HTML::HTML5::Parser;
my $output = $ENV{HTML_OUTPUT} || 'debug:json';
my $help;
GetOptions(
'output|o=s' => \$output,
'help|usage|h' => \$help,
);
if ($help)
{
my $name = $0;
print <<HELP and exit(1);
Usage: cat document.html | $0 --output=FORMAT
Reads HTML from STDIN and prints it out in a format useful for debugging.
Formats:
clarkml - ClarkML
debug - Debugging tree
debug:json - Debugging tree as JSON (default)
errors - List of errors
html - HTML
parser - Parser internals
parser:json - Parser internals as JSON
xml - XHTML
HELP
}
sub load
{
my ($pkg) = @_;
unless (eval "use $pkg; 1;")
{
die "This output format requires $pkg.\n";
}
}
my $p = HTML::HTML5::Parser->new;
my $h = join '', <>;
my $hash;
if ($output =~ /debug/i)
{
load('XML::LibXML::Debugging');
$hash = $p->parse_string($h)->toDebuggingHash;
}
elsif ($output =~ /clark/i)
{
load('XML::LibXML::Debugging');
print $p->parse_string($h)->toClarkML;
}
elsif ($output =~ /html/i)
{
load('HTML::HTML5::Writer');
print HTML::HTML5::Writer->new->document($p->parse_string($h));
}
elsif ($output =~ /parser/i)
{
$p->parse_string($h);
$hash = $p;
}
elsif ($output =~ /err/i)
{
$p->parse_string($h);
print "$_\n" foreach $p->errors;
}
else
{
print $p->parse_string($h)->toString;
}
if (defined $hash and $output =~ /json/)
{
load('JSON');
print to_json($hash, {pretty=>1,canonical=>1});
}
elsif (defined $hash)
{
load('Data::Dumper');
print Dumper($hash);
}
|