#!/bin/sh exec perl -S -x -- "$0" "$@" #!perl -w # $Id: update-html-bib,v 1.17 2017/09/25 15:16:25 jbw Exp $ use English; use strict; use User::pwent; my $JBW_Home; BEGIN { my $pw = getpwnam('jbw') || getpwnam('user') || die "Can't find user jbw or user: $OS_ERROR"; $JBW_Home = $pw->dir; push (@INC, "$JBW_Home/share/share/perl"); push (@INC, "$JBW_Home/church/lib/perl"); } use JBW::Utils qw(&with_file_contents &max &min); use Getopt::Long; use User::pwent; # This program uses bib2html to update the HTML bibliography in the # target file. my $Short_Prog_Name = $PROGRAM_NAME; $Short_Prog_Name =~ s(.*/)(); sub debug_print { #print STDERR "$Short_Prog_Name: @_\n"; } # Where bib2html is installed on local system. my ($Bib2HTMLDir) = "$JBW_Home/bib2html-1.33"; my ($Bib2HTMLProg) = "$Bib2HTMLDir/bib2html"; my ($HTMLBibFile, $AuxFile, $CiteFile, $BibDelim, $Bib2HTMLOpts, $ReverseNumericOrder); Getopt::Long::GetOptions ( 'html-bib=s' => \$HTMLBibFile, 'latex-aux=s' => \$AuxFile, 'html-cite-file=s' => \$CiteFile, 'bib-delim=s' => \$BibDelim, 'bib2html-opts=s' => \$Bib2HTMLOpts, 'reverse-numeric-order' => \$ReverseNumericOrder, ); if (! defined $HTMLBibFile) { die "must specify HTML bib file"; } if (! -f $HTMLBibFile) { die "Bad HTML bib file: $HTMLBibFile"; } if (! defined $AuxFile) { die "must specify LaTeX .aux file"; } if (! -f $AuxFile) { die "Bad LaTeX .aux file: $AuxFile"; } # RegenerateHTMLBib (HTML_BIB_FILE, AUX_FILE, BIB_NAME) # # (Re)generates an HTML formatted bibliography in a (possibly already # existing) HTML file. The bibliography contains entries specified in # the file given by the AUX_FILE argument. # # Arguments: # # HTML_BIB_FILE: target HTML file, may already exist # AUX_FILE: source file, .aux output of LaTeX # BIB_NAME: name of a bib2html section in target file # sub RegenerateHTMLBib { my ($HTMLBibFile, $AuxFile, $BibName) = @_; # bib2html uses special style files. However, it is too stupid to # set the environment variable to tell bibtex this. So we do it # here. $ENV{'BSTINPUTS'} = $Bib2HTMLDir; # bib2html options: # -a include abstracts # -c chronological sorting # -r reverse sorting order # -d XXX use XXX as part of delimeter marker in HTML file # -t FILE get \bibcite commands from FILE # -s STYLE use STYLE list labels # # (Dis)Advantages of various values for STYLE: # empty: # bullet lists --- hard to see crossrefs visually. # plain: # numbered list --- easy to see crossrefs visually, but # hard to read them directly. # alpha: # labelled list with "KW94" style labels --- somewhat # easy to see crossrefs visually, can be read directly # somewhat easily, but ugly. # named: # labelled list with "Kfoury and Wells, 1994" style # labels --- easy to see crossrefs visually, can be read # directly, fairly good looking, but sometimes omits # "Wells" due to author lists longer than 2 names. # Fixing requires hacking html-btxbst.doc, ugh. my $command = ("$Bib2HTMLProg -s plain " . ((defined $Bib2HTMLOpts) ? "$Bib2HTMLOpts " : "") . (((defined $BibName) && ($BibName ne '')) ? "-d $BibName " : "") . "-t $AuxFile $HTMLBibFile"); #debug_print "command: $command"; (system ($command) == 0) || die "system failed"; } RegenerateHTMLBib ($HTMLBibFile, $AuxFile, $BibDelim); # my (%Name_to_URL) = # ( # 'Jeffrey Considine' => 'http://cs-people.bu.edu/jconsidi/', # 'Allyn Dimock' => 'http://www.das.harvard.edu/users/students/Allyn_Dimock/Allyn_Dimock.html', # 'Fairouz Kamareddine' => 'http://www.cee.hw.ac.uk/~fairouz/', # 'A. J. Kfoury' => 'http://www.cs.bu.edu/~kfoury/', # 'Assaf J. Kfoury' => 'http://www.cs.bu.edu/~kfoury/', # # 'Harry G. Mairson' => 'http://www.cs.brandeis.edu/~mairson/', # 'Harry G. Mairson' => 'http://cs-people.bu.edu/mairson/', # # 'Robert Muller' => 'http://www.cs.bc.edu/~muller/', # 'Robert Muller' => 'http://oak.bc.edu/~muller/', # 'Alejandro Ríos' => 'http://www.dc.uba.ar/academic/profesor.htm', # # 'Franklyn Turbak' => 'http://www.wellesley.edu/CS/fturbak.html', # # 'Franklyn A. Turbak' => 'http://www.wellesley.edu/CS/fturbak.html', # 'Franklyn Turbak' => 'http://www-swiss.ai.mit.edu/~lyn/lyn.html', # 'Franklyn A. Turbak' => 'http://www-swiss.ai.mit.edu/~lyn/lyn.html', # 'René Vestergaard' => 'http://www.cee.hw.ac.uk/~jrvest/', # 'J. B. Wells' => 'http://www.cee.hw.ac.uk/~jbw/', # 'Ian Westmacott' => 'http://cs-people.bu.edu/ianw/', # ); # # # Convert the NAME->URL mapping into NAME_PATTERN->REPLACEMENT_TEXT format. # my (%NamePatt_to_LinkedName); # { # my ($Name); # foreach $Name (keys %Name_to_URL) { # #print "Name: [$Name]\n"; # my ($ReplacementName) = $Name; # while (($ReplacementName =~ s/ / /g) >= 2) { # $ReplacementName =~ s/ / /; } # my ($NamePatt) = $ReplacementName; # $NamePatt =~ s/ /\\s+/; # #print "NamePatt [$NamePatt]\n"; # my ($URL) = $Name_to_URL{$Name}; # my ($Replacement) = "$ReplacementName"; # #print "Replacement [$Replacement]\n"; # $NamePatt_to_LinkedName{$NamePatt} = $Replacement; }} # # # Rewrite file using the mapping %NamePatt_to_LinkedName. # with_file_contents $HTMLBibFile, sub { # my ($PreNamePatt) = '