Couple of version/copyright updates
[exim-website.git] / script / eximhtml2txt.pl
1 #!/usr/bin/env perl
2 #
3 use strict;
4 use warnings;
5
6 use HTML::FormatText;
7 use HTML::TreeBuilder;
8
9 sub process_chapter {
10     my $fn = shift;
11
12     my $tree = HTML::TreeBuilder->new->parse_file($fn);
13     my ($chapter) = $tree->look_down( "_tag", "div", "class", "chapter", );
14     return '' unless ($chapter);
15     my $formatter = HTML::FormatText->new( leftmargin => 0, rightmargin => 72 );
16
17     my $text = $formatter->format($chapter);
18     $tree->delete;
19     return $text;
20 }
21
22 my $dir = shift;
23 foreach my $fn ( glob("$dir/ch*.html") ) {
24     print "=" x 72, "\n";
25     print $fn, "\n";
26     print "=" x 72, "\n";
27     print process_chapter($fn);
28     print "-" x 72, "\n";
29 }