#!/usr/bin/perl # normalize HTML # # TODO: strip comments use Getopt::Long; use File::Slurp; use strict; use warnings; my $force; GetOptions ("force|f"); my $stem = shift; my $_ = read_file( $stem . '.htm' ); # whitespace s/ / /mg; # page header s{
]*;top:6[23]px;[^>]*>[^<]*
\s*}{}mg; # footnote foreach my $class ( map /(?<=\.)(ft\d+)(?={font-size:7px;)/mg, $_ ) { s{\(\s*]*\sclass="$class">\d+
\s*]*>\)}{}mg; }; foreach my $class ( map /(?<=\.)(ft\d+)(?={font-size:6px;)/mg, $_ ) { s{
]*>\(
\s*]*\sclass="$class">\d+
\s*]*>\) [^<]*
\s*}{}mg; }; # drop document headers s{.*?\s*}{}msg; s{\n