zoteroRoam
Report an issueRoadmap
v0.6
v0.6
  • Introduction
  • โ–ถ๏ธDemo by Cortex Futura
  • ๐Ÿ”„Updating from older versions
  • ๐Ÿš€Changelog
  • ๐Ÿ†˜Help/Getting Support
  • ๐Ÿ Getting Started
    • 1.1 Pre-requisites
    • 1.2 Installation in {{roam/js}}
    • 1.3 Basic Setup
  • ๐ŸงชUsing the extension
    • 2a. The search panel
    • 2b. In-text references
    • 2c. On-page menu
    • 2d. Contextual buttons
  • ๐Ÿ› ๏ธCustomizations
    • 3.1 What's Available
    • 3.2 Constructing data requests
    • 3.3 Creating your own formatting functions
      • Nesting metadata
      • Code snippets
    • 3.4 Creating custom shortcuts
    • 3.5 Customizing on-page displays
    • 3.6 Other Settings
      • autoload / autoupdate
      • autocomplete
      • funcmap
      • typemap
      • notes
      • Copying an item's reference
      • theme
    • Advanced : using event hooks
    • Extension defaults
  • About the Zotero API
    • Zotero API Docs (v3)
  • Support the project
    • How to support/contribute
    • Buy me a (virtual) coffee
    • GitHub Sponsorship
Powered by GitBook
On this page
  • Value
  • Usage in the extension
  • Examples

Was this helpful?

  1. Customizations
  2. 3.6 Other Settings

funcmap

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

Last updated 4 years ago

Was this helpful?

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 .

  • 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 .

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

  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"
    }
}

Assigning custom functions to a few item types - no use of DEFAULT

Assigning a custom function for a specific item type (book section) + use of DEFAULT

๐Ÿ› ๏ธ
โœ๏ธ
โœ๏ธ
here
Type-specific properties
DEFAULT property