dump nicely formatted text for grep
[Printer-EVOLIS.git] / docs / parse-html.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 open(my $html, '<', 'Programming_Guide_A5013_RevEs.html') || die "run pdftohtml: $!";
7
8 sub strip_html {
9         my $t = shift;
10         $t =~ s{&nbsp;}{ }gs;
11         $t =~ s{(<br>|\n)+}{}gs;
12         $t =~ s{\s+$}{}gs;
13         return $t;
14 }
15
16 while(<$html>) {
17         next if m{^(&nbsp)?Page \d+};
18         if ( m{<b>(\w+)&nbsp;</b><br>} ) {
19                 my $command = $1;
20                 my $param = <$html>;
21                 next if $param =~ m{Page #};
22                 my $description = <$html>;
23                 printf "%-4s %-15s %s\n", $command, strip_html($param), strip_html($description);
24         }
25 }
26