#!/usr/bin/perl
open(RFH,$ARGV[0]) || die $!;
while(<RFH>){
	$tex_content .= $_;
	}
close RFH;
open(WFH,$ARGV[1]) || die $!;
while(<WFH>){
    $wtex_content .=$_;
}
close WFH;
while ($wtex_content =~ m{(tex4ht=new Array\(\) ; //\d\d\d\d-\d\d\-\d\d \d\d:\d\d:\d\d)}gms){
    print $1;
    print "\n";
}
$counterofnumoffootnote = 0;

while ($tex_content =~ m{<footnote>(fn\d+\w\d+=)(<div class=\"js\"><span class=\"footnote-mark\"><a\s+id=\"fn\d+\w\d+\">\s+<sup >\d+</sup></a></span>.*?</div>)</footnote>}gms) {
    $idoffootnote = $1;
    $temp_contentsoffootnote = $2;
    $temp_contentsoffootnote =~ s{\s+}{ }gms;
    $temp_contentsoffootnote =~ s{\\\"}{\\\\\"};
    $temp_contentsoffootnote =~ s{\"}{\\\"}gms;
    push(@listofcontentsoffootnote,$idoffootnote,$temp_contentsoffootnote);
    print "tex4ht.@listofcontentsoffootnote[$counterofnumoffootnote]";
    $counterofnumoffootnote++;
    print "\"@listofcontentsoffootnote[$counterofnumoffootnote]\"\;\n";
    $counterofnumoffootnote++;
}

$counterofnumofbibitem = 0;
while ($tex_content =~ m{<bibitem>(\w+=)(.*?</p></div>)</bibitem>}gms) {
    $idofbibitem = $1;
    $temp_contentsofbibitem = $2;
    $temp_contentsofbibitem =~ s{\s+}{ }gms;
    $temp_contentsofbibitem =~ s{\\\"}{\\\\\"};
    $temp_contentsofbibitem =~ s{\"}{\\\"}gms;
    push(@listofcontentsofbibitem,$idofbibitem,$temp_contentsofbibitem);
    print "tex4ht.@listofcontentsofbibitem[$counterofnumofbibitem]";
    $counterofnumofbibitem++;
    print "\"@listofcontentsofbibitem[$counterofnumofbibitem]\"\;\n";
    $counterofnumofbibitem++;
}
print "ol_hauto = 1;";
