Bibhtml

This documentation describes bibhtml, version 1.1, 6 June 1999.

Contents

  1. Introduction
  2. Usage
  3. Running bibhtml
  4. Installation
  5. MacPerl and two-pass bibhtml
  6. Example
  7. Getting bibhtml
  8. Licence

Introduction

Bibhtml consists of a Perl script and a BibTeX style file, which together allow you to compile a bibliography for a collection of HTML files. The references in the text are linked directly to the corresponding bibliography entry, and if a URL is defined in the entry within the BibTeX database file, then the generated bibliography entry is linked to this.

The BibTeX style file is plainhtml.bst, and is derived from the standard plain.bst. You can obviously generate alternative versions of this style file in the same way as you can with LaTeX, and specify them to bibhtml using the -s option. The file plainhtmldate.bst is an example of such a file, which produces its output in date order. If you do this, please do not call the changed file plainhtml.bst, to avoid confusion.

The BibTeX style files distributed as part of this package are also of considerable use in isolation.

Usage

The BibTeX database

Bibhtml works with a standard BibTeX database -- it is intended to be compatible with a database used in the standard way with LaTeX. The BibTeX style files distributed with this package define an additional url field: if this is present, then the generated entry will contain a link to this URL. They also define an eprint field -- if you do not use the LANL preprint archive, this will be of no interest to you.

TeX features such as ~ and -- are translated to corresponding HTML entities (controlled with the +3 switch, see below), but other TeX constructions will make their way into the generated HTML, and look a little odd. I might try to deal with these in future versions.

Preparing the text

You prepare your text simply by including links to the bibliography file (the default is bibliography.html), followed by a fragment composed of the BibTeX citation key. Thus, you might cite [grendel89] with

<a href="bibliography.html#grendel89">(Grendel, 1989)</a>

(of course, the link text can be anything you like). That's all there is to it. When you run bibhtml, it generates an .aux file which makes BibTeX produce references for exactly those keys which appear in this way.

Preparing the bibliography file

The bibliography file is an ordinary HTML document (which may itself have citations within it), distinguished only by having two magic comments within it. Bibhtml replaces everything between <!-- bibhtml:start --> and <!-- bibhtml:end --> (which should be on lines by themselves) with the formatted bibliography. It leaves those comments in place, naturally, so once this file is set up, you shouldn't have to touch it again.

As a special case, bibhtml also replaces the line after a comment <!-- bibhtml:today --> with today's date.

BibTeX style files

bibhtml depends on several BibTeX style files. plainhtml.bst, plainhtmldate.bst and plainhtmldater.bst are derived from the standard plain.bst. All produce HTML, but the latter two sort the output by date and reverse date, rather than by author. alphahtml.bst and friends were derived from the standard alpha.bst, and contributed to the package, by Franz G. Fischer, Franz.Fischer@lpr.e-technik.tu-muenchen.de, to whom thanks are due.

Although these style files are distributed as part of bibhtml they are also useful in isolation, as part of a larger system which generates HTML.

Running bibhtml

Bibhtml takes a list of HTML files as argument (though see below for a two-pass variant). It creates an .aux file, runs BibTeX, and merges the resulting .bbl file (if it exists) into bibliography.html, or whatever has been specified as the bibliography file name.

There are several options:

-r rootname
Specify this and you'll create rootname.html, rootname.aux and so on. Why not just stick with the default `bibliography'...?
-b bibdata
The name of your BibTeX database file, as it would be specified in a \bibliography{} command in LaTeX. Unless you happen to keep all your references in a file called bib.bib, you'll probably want to change this.
-s bibstyle
The name of the BibTeX bibliography style you want to use, as it would be specified for the \bibstyle command in LaTeX. If you want to have a different layout for your HTML bibliographies, please don't change the file plainhtml.bst distributed with bibhtml. Instead, make a copy of plainhtml.bst under a different name, edit it as much as you like, and use this option of bibhtml to use the modified version instead of the default.
-c configfile
Specifies a configuration file which contains a single line of options, which are inserted in the command line at that point.
-3, +3
Set this to +3 if you want ~ translated to &nbsp;, and -- to &enspace;. Or set it to -3 (the default) if you don't.
-v, -q
Do you want the program to be verbose or quiet? The default is -v, verbose.
-a
If this option is set, bibhtml won't bother scanning any files at all, and will generate references for all the entries in your database. This is equivalent to \nocite{*} in LaTeX.
--version
Bibhtml prints the version information and exits.
--merge
In this special case, bibhtml takes two arguments, a .bbl file and an .html file, merges the first into the second, and nothing else. It's intended to be used when you have generated a .bbl file by a separate run of BibTeX, and simply wish to merge the results into your bibliography file. As such, it will most likely be useful as part of a script, or other post-processing system.

The defaults for the various parameters are unlikely to be helpful, so you're likely to want to set one or more of them every time you run the program. It is for this reason, and because you're likely to want the same set of options every time you create the bibliography for a set of files in a directory, that you can put a collection of options in a configuration file. This can be specified on the command line with the option -c configfilename. If this option is not given, then bibhtml looks for a file named bibhtml.config. For example, the configuration file might contain:

-b mybib +3 -r refs

Installation

Nothing to it.... On Unix, for example, put bibhtml somewhere in your path and make it executable (chmod u+x bibhtml), and put *.bst somewhere BibTeX will find it (this means either looking at the environment variable BSTINPUTS, or running the command kpsepath bst, if you have it). If you want to use the two-pass variant of the program, then make a symbolic link with ln -s bibhtml bibhtml2.

If you wish, you may change the distributed BibTeX style files (see above) to the extent of changing the `eprint' mirror site from the master xxx.lanl.gov to a more local mirror. If you don't use the LANL preprint archive, this will be of no interest to you.

MacPerl and two-pass bibhtml

Perl's system() command obviously won't work on a Mac, and I don't believe that either of the well-known BibTeX ports is yet Apple-scriptable. Consequently, I can't persuade Perl to run BibTeX for you, so you have to do it by hand. This means you must first create the .aux file using bibhtml, then run BibTeX, then run bibhtml again, to merge the newly generated .bbl file into the bibliography (and redundantly generate a fresh .aux file).

If you're using MacPerl, you can create a MacPerl droplet by opening bibhtml and saving it as a droplet, giving it the name `MacBibhtml'. To use this, drop a selection of .html files on to it, and it will generate an aux-file. Run BibTeX, and then drop the generated bbl-file onto MacBibhtml again.

MacPerl is available in ports/mac on CPAN.

On Unix, you might have a need to invoke the two phases separately. If you make a symbolic link to the program via ln -s bibhtml bibhtml2 (the name doesn't actually matter, as long as it isn't called `bibhtml'), then you can generate an aux-file alone by giving the command bibhtml2 *.html, say; and you can merge a bbl-file into the bibliography file with the command bibhtml2 bibliography.bbl. You can do the same thing on the Mac by duplicating the MacPerl droplet and giving it the name bibhtml2. The command line option --merge above may be more suitable if you are calling this code from a script, as it requires you to specify both the .bbl and the .html file it is being merged with, (and so it is more robust, and more flexible).

On both the Mac and on Unix, this works because the program is able to detect the name it was invoked under. This may be more difficult on other platforms. If so, please get in touch, with suggestions.

Example

[brown95] gives a clear discussion of the problems of citing electronic documents, as do Walker and Emory.

This file was processed with the command bibhtml -b bibrefs -r bibhtml bibhtml.html to produce the document you are reading now.

References

[brown95] Haines Brown.
Citations of electronic documents in an electronic document. World Wide Web page, 1995.
[emory95] libsf@web.cc.emory.edu.
Citation formats. World Wide Web page, 1995.
[walker95] Janice R Walker.
MLA-style citations of electronic sources. Technical Report 4/95, Department of English, University of South Florida, January 1995. Endorsed by the Alliance for Computers and Writing.

Obtaining bibhtml

Bibhtml is available on CTAN, and at http://www.astro.gla.ac.uk/users/norman/distrib/bibhtml.html.

Download the distribution: bibhtml-1.0.tar.gz.

Do let me know if you use this stuff. I'd be grateful for any bug reports, and bug fixes, and also for any comments on the clarity or otherwise of this documentation.

Licence

This software is copyright, 1999, Norman Gray. It is released under the terms of the GNU General Public Licence. See the copyright declaration at the top of file bibhtml, and the file LICENCE for the licence conditions. You can find an online copy of the GPL at http://www.gnu.org/copyleft/gpl.html.


Norman
6 June 1999