Now that I have a more professional website, I wanted to include on it a list of publications. It took me a while to figure out a "good" way to do this, and many things I tried didn't work, so here's the solution I eventually settled on.
Maybe it can help you too!
My list of publications, though not huge yet, is stored in Bibtex format. I wanted a way to embed that nicely on a website. Since the same bibtex files feed other documents, I didn't really want to retype them in HTML markup. Instead I wanted something which would take the data directly out of the Bibtex files and put it in a format where I could use CSS to style it myself.
Some options I found after searching for a while:
- Bibbase.org would probably actually be fine. It takes a Bibtex file hosted anywhere, and transforms it into a fancy, viewer-sortable, CSS-stylable list. It allows this list to be embedded via PHP, Javascript or frame into another webpage. The only reason I didn't take this, is that I couldn't find a way to control how it looked (except CSS), and the list seems to be built using Ajax, which is really unnecessary imo. I think overuse of Ajax is a scourge on the web :) That said, it is super easy to use and probably the best solution for most people.
- There are a number of static Bibtex-to-html tools, such as bibtex2html, and tex2_rst_html, the latter of which actually looked pretty good, but in trying to install it it led me down a pip-chain of dependencies which ended in a 404, so I had to give up.
- There are some Latex bibliography styles which render Bibtex bibliographies as HTML. I couldn't get any of them to work especially easily and most require editing XSLT or Bibtex style files to change how they look. Besides, while a static Bibtex-to-XML/HTML converter would have been OK, I'd much prefer a live PHP-driven converter.
- PhpBibLib looked perfect, but I just couldn't get it to do what I wanted, and I don't know PHP well enough to do proper debugging.
Eventually I found:
- Bibliophile Bibtexparse (mirror), which was being distributed as part of a WordPress plugin (which itself was no use to me). This is exactly what I wanted.
For the PHP-semi-literate (such as myself), you use it like this:
- Upload the files somewhere visible from the PHP page in which you want your publication list.
- At the top of your PHP page, add
<?php include 'bibtexParse/PARSEENTRIES.php' ?> <?php include 'bibtexParse/PARSECREATORS.php' ?>
Where the paths indicate where you uploaded the files.
ParseEntries()
will take a.bib
file and convert it into a PHP array. It is invoked like this:<?php $parse = NEW PARSEENTRIES(); $parse->expandMacro = FALSE; $parse->removeDelimit = TRUE; $parse->fieldExtract = TRUE; $parse->openBib("publications.bib"); $parse->extractEntries(); $parse->closeBib(); list($preamble, $strings, $entries, $undefinedStrings) = $parse->returnArrays(); ?>
Where the meaning of the various parameters can be found in the documentation.
- Then,
$entries
is a PHP array of bib entries which can be listed in the following way:<?php foreach ( $entries as $entry ) { ?> <li class="publication"> <?php $title = $entry["title"]; ?> <span class="publication-title"><?php print($title); ?></span> </li> <?php } ?>
etc.
ParseCreators()
also allows the conversion of the and-delimited list of authors in a Bibtex entry into a PHP array of author names:<?php $creator = new PARSECREATORS(); foreach ( $entries as $entry ) { ?> <span class="publication-authors"> <?php $authors = $creator->parse($entry["author"]); $author_full_names = array(); foreach ($authors as $author) { $author_full_name = implode(' ', $author); $author_full_names[] = $author_full_name; } $author_full_names = array_map('trim', $author_full_names); $author_list = implode(', ', $author_full_names); print($author_list); ?> <span> <?php } ?>
- Since the markup is user-written, the style of the publication can be chosen at will, and can be formatted using CSS.
ParseEntries()
looks like it will do a bunch of Bibtex-supported things like macros and strings (which I don't use), and also has the benefit that it can parse arbitrary "unsupported" fields. So I used apdf = {path/to/file.pdf}
field in my bibliography to include a link to a file, and adoi = {doi}
field to automatically produce a link to the publication's DOI.
Because it's live-rendered in PHP, it would be straightforward enough to have it automatically render me a CV if I wanted. Problem solved.
I'm currently using it to generate a couple of pages on my site.
Thank you! I was searching for bibbase website. I used it before, but just could not remember its name!
Thank you again!
Glad it was helpful! :)