Helper functions
To help you write your own templates in JavaScript, the extension provides helper functions via a global object - zoteroRoam. You may have come across them in the Getting Started section, in the code for the default formatting function.
All available functions are described below ; note that the arguments item, pdfs, and notes correspond to the arguments your custom function receives from the extension.
// Let's say you're writing a custom function called myFunction
// It will be passed 3 arguments by the extension, in order:
// - item: the raw metadata for the Zotero item
// - pdfs: the raw metadata for the PDF(s) linked to the Zotero item
// - notes: the raw metadata for the notes/annotations linked to the Zotero item
window.myFunction = function(item, pdfs, notes){
let metadata = [];
// Inside of your function, you can use helpers like so:
metadata.push(`Type:: ` + zoteroRoam.getItemType(item));
if(notes.length > 0){
metadata.push({
string: "[[Notes]]",
children: zoteroRoam.formatNotes(notes)
})
}
return metadata;
}List of functions
Last updated
Was this helpful?