[OS X TeX] Re: html output from bib file (BibDesk)

James Owen jhgowen at mac.com
Tue May 23 00:56:47 EDT 2006

> On 23 May 2006, at 10:49, Chris Volinsky wrote:
> james,
> I just read through your thread on macoxtex about your frustration of
> getting bibdesk to do what you wanted it to.  I, too, am going through
> similar frustrations...as I would like to customize  the html
> generated from the export function .  You mention that you have export
> templates from bibdesk that you would be willing to share.  I'd be
> grateful if you did share them along with perhaps a little advice to
> help me figure out how to use them!
> thanks!  I really like the bibdesk interface for maintaining
> refs...now if I could only output them in sensible html I'd be real
> happy.
> cheers,
> chris

Dear Chris,

As a result of that thread or the one on the BibDesk-Users mailing
list, Adam Maxwell has made some
changes to BibDesk. If you download one of the latest nightlies, (A
recent one is broken, so wait a
day or so, to get the latest one. I am using 20060519) you will find
an extra preference pane, entitled "Export".
This will have a list of templates for html files.

The default one is listed under "Default Template". If
you click on the down arrow, you will see this includes two files :
"htmlExportTemplate" and
"htmlItemExportTemplate". These refer to two files in the folder ~/
Library/Application\ Support/BibDesk/

If you go to that folder manually in the Finder, and open those two
files in a text editor, you will see that they
are html files, with fields from the BibTeX database as <
$pubfields.Author> etc.
If you know html at all, then the layout of these templates will be
clear to you. The main exporttemplate file
has some css to format the html output, but you can replace that with
your own css easily.
If you don't know html and css at all, then these files won't make  
much sense to you.

Personally, I have edited the ItemTemplate files to add in the DOI,  
and also to give each reference an id
which I can use to refer to them when I am writing webpages.

I am attaching slightly modified versions of the two template files  
that I use in my own webpages, which can be seen at:
exportpagescsstemplate is the main template file. I have included the  
css formatting into the html file, rather than the external
css file that I use.
shortandfullnames.html is the item template file. I have included two  
author lines to illustrate some of the options that you have.
The first line has the short names of the authors separated by  
commas, and the second line has the full names. These things are  
options contained within the BibDesk program, but so far as I know  
there is no documentation of them.

If you wish to use these directly, without significant modification,  
it would be nice if you acknowledge where you got them from. You  
should also acknowledge the great work of the BibDesk authors that  
makes this all possible somewhere on your webpage.

In order to make use of these, go back to the Export pref pane, and  
follow these steps.

1:  click once on "Default Template" and then click on the + button  
at the bottom right corner. This will create a new template named  
"Double-click to change name." Double click on it to change its name  
to something else, e.g. "New Template".

2: click on the grey arrow which will bring up another item in red  
called "Double-click to choose file".

3: Double click on the red filename to bring up a standard dialog box  
where you choose the main template file, in this case

4: Then click to the right of where it says "Accessory File" on the  
up-down arrow pair. This brings up a menu, select "Main Page".
This tells BibDesk what role that file is playing. That column is  
entitled "Role" for this reason. Alternatively, click on the words  
"Accesory File" and start typing "Main Page" and it will autocomplete.

5: With "exportpagecsstemplate.html" selected, click on the + button  
again, to create a second template file.
Repeat steps 3 and 4 on this second file to select  
"shortandfullnames.html" and to define its Role as "Default Item".

You should now have a new template, containing the two template files  
which I have attached below, and which you should place in ~/Library/ 
Application\ Support/BibDesk/. In order to generate an html file, go  
to your BibDesk database file (.bib file), select one or more  
references, go to the File menu, select "Export Selection..." and  
then "HTML". This will bring up a save dialog box.
At the bottom of the dialog box, there is a button marked "Export  
Template" where you can select which template to use. Choose either  
"Default Template" or  "New Template". Type in the name of the output  
html file at the top, select a folder for it to save to, and click  

Your new html file will now be located in your chosen folder. Open it  
up, and hopefully it will be what you want. There is a bug that  
sometimes BibDesk ignores your selection, so it may have produced an  
html file of the whole bib file, but hopefully that has been or will  
soon be fixed.

Hope that helps. I am posting to the BibDesk-Users and Mac OS X  
mailing lists in case other people are also interested.
Note that the Export pref. pane is very new, and the details may well  
change over time.

James Owen

P.S. The TeX mailing list of course does not support attachments, so  
here I have posted the two files into the email instead.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<style type="text/css">
@media print {
   /* style sheet for print goes here */

.content {background-color: #fffeec;
		text-align: justify;
		float: right;
		width: 95%;
		padding: 10px 1%;
		margin: 10px 1%;
         border-style: solid;
		border-width: 1px;
		border-color: #ead388;
.Pub, .Talk, .Poster {
	text-align: left;
	font-size: 0.9em;
	line-height: 125%;
	page-break-before: always;
	padding-bottom: 0.8em;
.Title { font-weight: bolder;
		 font-size: 1.0em;
		 color: #225522;
.Author {color: black;}

.Journal, .Conference {font-style: italic;}

.Volume {font-weight: bolder;}

.Year {color: black;}

.Citations {font-size: 0.8em;
			color: #3d433b;

.url { font-size: 0.8em; color: #c95e62;}

<div class="content">
<li class="Pub" id="<$citeKey/>">
	<span class="Title"><$pubFields.Title/></span>
	<br />
         <span class="Author">< 
$pubAuthors.abbreviatedName. at componentsJoinedByCommaAndAnd/></ 
span><br />
	<span class="Author">< 
$pubAuthors.name. at componentsJoinedByCommaAndAnd/></span><br />
	<span class="Journal"><$pubFields.Journal/></span> 
	<span class="Volume"><$pubFields.Volume/></span> 
	<span class="Pages"><$pubFields.Pages/></span> 
	(<span class="Date"><$pubFields.Year/></span>) 
	<span class="url"><a href="http://dx.doi.org/<$pubFields.Doi/>">< 
	<span class="Citations"><$pubFields.Citations/> Citations</span>

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/

More information about the MacOSX-TeX mailing list