funcmap

The funcmap setting lets you assign your own formatting functions to specific item types

Value

An Object containing zero or more type-specific properties - named after the Zotero item types - and an (optional) DEFAULT property.

Type-specific properties

Each property should be defined as follows :

  • Name : the property name has to follow the Zotero data scheme. An old nomenclature of item types is available here.

  • Value : the property's value should be a string, corresponding to a function name.

For example, defining funcmap.book with the value "customBookFormat" will have the extension use the customBookFormat function for all items of type book.

DEFAULT property

If the funcmap.DEFAULT property is defined, the extension will always fall back on the function it names if no specific function has assigned to an item's type. >> The extension's built-in metadata template will never be used.

Usage in the extension

When importing an item's data into Roam, the extension will first check the item's type (i.e, its data.itemType property) and use it to look for the name of the formatting function that should be used to produce Roam blocks.

The extension's query path will check the existence of the following, and use the first defined value :

  1. zoteroRoam_settings.funcmap[itemType], which can be used to provide a specific formatting function for a particular item type. See Type-specific properties.

  2. zoteroRoam_settings.funcmap.DEFAULT, which can be used to provide a user-defined default formatting function. See DEFAULT property.

  3. The extension's built-in formatting function, getItemMetadata .

Examples

// This presupposes the following :
// window.customBookFormat = function(item){ ... }
// window.customPaperFormat = function(item){ ... }

// For item types other than Book | Conference Paper | Journal Article,
// the built-in function getItemMetadata will be called.

zoteroRoam_settings = {
    // dataRequests: {...},
    funcmap: {
        book: "customBookFormat",
        conferencePaper: "customPaperFormat",
        journalArticle: "customPaperFormat"
    }
}
// This presupposes the following :
// window.customChapterFormat = function(item){ ... }
// window.customDefaultFormattingFunction = function(item){ ... }

// The built-in function getItemMetadata will never be called.

zoteroRoam_settings = {
    // dataRequests: {...},
    funcmap: {
        bookSection: "customChapterFormat",
        DEFAULT: "customDefaultFormattingFunction"
    }
}

Last updated