BibDesk provides a convenient means to create a database of references to include in a bibliography using the standard LaTeX/BibTeX route.
However, BibDesk can also export a whole database, or a selection of the database, to a number of other formats, including HTML, RTF, and the Word DOC format. In fact, it is possible to write a custom export template for any structured text format! You can find a brief explanation of the use of templates for export in the manual, also included in the BibDesk Help Menu. This page will expand upon the information in the manual, and describe how to create templates to meet your own needs, and how to set up BibDesk to use your own templates.
This page will mainly concentrate on describing the export to HTML files. Beyond their obvious application as files for web bibliographies, HTML is a common import format in many word processors, such as Apple's Pages and TextEdit, Microsoft Word et al. Thus an HTML template can also be used as a template for export to these programs.
Below, there is a list of custom templates which have been written by BibDesk users; for further discussion or to announce that you have posted a new template here, use the BibDesk-users mailing list.
BibDesk uses templates in various places. Apart from export, templates are used for the pretty printed previews in the main window, copying, and services, and moreover can be used for dragging and emailing.
The Export submenus can be found in the File menu of BibDesk. You can either export the whole database, or just the references which you have selected.
To use the default template, select the "HTML" item from the export submenu. A standard save box will then open, allowing you to choose the name of the html file, and also the location on your hard drive. In order to use a non-default template the last menu item "Using Template" should be selected. This also leads to a save box, but with the addition of a dropdown menu at the bottom of the save box where a template can be selected. The file extension should change to reflect the output format, i.e. html, rtf, doc etc.
You can find a set of default template files in the folder ~/Library/Application Support/Bibdesk/Templates. For HTML export, there are 3 template files: htmlExportTemplate.html, htmlItemExportTemplate.html and htmlExportStyleSheet.css. Generally, only the first of these template files is required. You can also find these template files from the Templates pane in BibDesk's Preferences. Click on the triangle to the left of "Default HTML template" to reveal the list of template files for this template. Control-click or right-click on a file in this list to either reveal it in a Finder window, or open the file with your favorite viewer or editor.
Looking at the htmlExportTemplate.html file first, this is a relatively simple html document, with a standard header, a link to the external CSS file, and a single "content" div in the body. The formatting of the individual entries into the html file is done using the htmlItemExportTemplate.html file. Opening this file, you will see that the template files comprise a series of items enclosed in < and > signs, the same as those used in HTML to enclose formatting tags, but starting with an extra $. These entities are known as Template Tags. They are parsed by BibDesk to include the relevant parts of the BibDesk database in the html file. For example, <$fields.Title/> will be replaced by the contents of the "Title" field in the BibDesk database. A list of the different kinds of Tag is given in the Template Keys page in the manual. It is also possible to apply modifiers to the field Tags in order to format the contents. One example is the <$fields.Authors/> Tag where the full name or an abbreviated name can be chosen, and the "and"s between authors can be replaced by commas. These modifier keys are also listed at the Template Keys page in the manual.
For the formatting of the fields, I have set each field as a <div> or <span> with a class or id. Then I have used a separate CSS file to define the formatting of each field. This also allows for different formatting to be used for online view or for printing out. In my case, the online view is part of my base.css file, while I have a separate print.css file, which removes most of the colouring, and the different font sizes, and makes it more plain. Since this is not meant to be an HTML/CSS tutorial, I will not explain further how to achieve the desired effects. One point of note is that I use the print.css file when importing bibliographies into a word processor. Different programs have different import methods. One thing I have noticed is that Pages, part of Apple's iWork suite, will take account of CSS formatting, although it reads from both the base.css and the print.css files. Microsoft Word on the other hand, completely ignores any CSS formatting, and imports the plain HTML file. Score one for Pages.
You can save your templates anywhere in principle. However, it is probably tidiest to keep them in the aforementioned Templates folder. Before you are able to use them however, you need to tell BibDesk where they are, and what role each file should play in the template.
In order to make use of your own template, go to the Templates preference pane in BibDesk, and follow these steps. Let's assume that you have created two files, "NewMainTemplate.html" and NewItemTemplate.html".
You can also drop all the template files on the table to add the templates. If there is more than one file, you will be asked to select which one to use as the main template file (the one with role Main Page). This will replace (most of) steps 1, 3, and 5 above.
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 "Using Template". This will bring up a save dialog box. At the bottom of the dialog box, there is a button marked "Using 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 "Save". If your new template does not show up in this list, then try quitting BibDesk and restarting it to clear up any glitches.
This is a list of custom templates you can use with BibDesk.
Wiki: Export_Templates
Wiki: FAQ
Wiki: Format_Citations_for_Editors
Wiki: Main_Page