Easy way to take a Zotero item and format it into a plain-text Harvard style citation

I'm currently writing a translator to export my collections into a specific JSON format for another project. For each collection I'm retrieving the Item objects and manually generating plain-text Harvard style citations by just piecing together the Item's properties.

I feel like I'm re-inventing the wheel and it's quite time-consuming, is there an easy way to achieve this? Say with the Zotero API
  • edited December 27, 2020
    If you want it in json then why are you formatting it in Harvard style?
  • edited December 28, 2020
    Sorry if I wasn't clear, I have a JSON object which *contains* an array of plain text references. So to be clear the problem is generating a plain text Harvard style reference from a Zotero Item, it being in a JSON object is just Context.
  • Still not entirely clear what the process is (if you have a JSON array of plaintext references, why still generate them?) but if you need to generate plain-text references from Zotero items, I'd say run them through the built-in citeproc rather than using a translator (which can't access citeproc -- not without significant effort anyway). Citeproc can generate HTML which is easy to convert to plaintext. Alternately, it's also possible to plug a plain-text renderer into Zotero's citeproc, but that's going to be more effort than just converting HTML to plaintext.
  • Could we take a step back?

    What is the data format you have (if not in Zotero)? What output format do you want? And what does Zotero have to do with it?
  • One particular question I have (I agree with bwiernik that some background would be very helpful) is what you mean by "Harvard" -- if it's just the author-date citations (Smith 1776), that's obviously pretty easy to just construct from the raw items in an export translator. If you do want full citations, then, yes, some solution that takes advantage of Zotero's ability to format citations is likely a good idea.
  • Sorry for the confusion. Looking at citeproc this may be the solution I'm looking for, I just need to test it first.

    To clear things up, I am working on a dataset of archaeological data, the data is in a JSON format and holds an array of objects. Each object represents a site, and each object has a string array containing a bibliography for that site. I wanted to use Zotero in such a way that I could have a collection represent one site, the items within that collection would represent that sites bibliography. What I've been trying to do is write an exporter to take my collections and produce a JSON array which can be used in this aforesaid dataset. That means taking the items within a collection and generating plaintext references which can be inserted into the JSON array of a specific object.

    It's a requirement that these be in the Harvard style of referencing (https://www.mendeley.com/guides/harvard-citation-guide).

    Thanks
  • edited December 28, 2020
    So you want to export selections of your library (collections in your case) to JSON arrays of harvard-formatted bibliography entries.

    How to do this depends on the fidelity you need. If it's OK that they're sorta-Harvard-usually then it would be easiest in a translator. If you want to make sure all the sometimes-inane citation rules are followed (high-fidelity) I'd personally go with either calling citeproc from within zotero (which means creating a plug-in or a script for the script runner) or talking to the Zotero API (which can export bibliography items if I'm not mistaken).
Sign In or Register to comment.