#!/usr/bin/perl # this works with bibtex2html 1.74 now. my $remove_numbers = 1; # remove the [1] numbers my $stylesheet = ''; my $abssuffix = ''; my $file = $ARGV[0]; unless ($file) { print "Remove abstracts from bibliography HTML file and put them into separate documents.\n"; print "Usage: ./pubabstract.perl infile.html >outfile.html\n\n"; exit; } my $path = $file; $path =~ s/\/[^\/]+$/\//; my $content = ''; open IN, $file || die("couldn't open $file!"); while() { $content .= $_; } close IN; # this was used for earlier bibtex2html versions # $content =~ s/(<\/a>.*?)(
\s*\[\s*)(
|
.*?<\/blockquote>)/&repl($1,$2,$3,$4,$5);/eisg; $content =~ s/(\[\s*[0-9]*<\/a>.*?)(
\s*\[\s*)(
|
.*?<\/blockquote>)/&repl($1,$2,$3,$4,$5);/eisg; print $content; sub repl($$$$$) { my ($pre1, $name, $pre2, $lnk, $abstract) = @_; # remove numbering if($remove_numbers ) { $pre1 =~ s/\[.*\]/ /s; } if ($abstract =~ /
(.*?)<\/blockquote>/is) { my $abtxt = $1; my $absdoc = $name."-abstract.html"; unless(open OUT,">$path$absdoc"){die("couldn't write to $path");} print OUT '
Abstract'.$stylesheet.'

Abstract

'.$abtxt.'

'; print OUT '

[Close window]

'; close OUT; return $pre1.$pre2."abstract | ".$lnk; } else { return $pre1.$pre2.$lnk.$abstract; # no abstract found } }