Skip to content

Scripting

retorquere edited this page Sep 7, 2015 · 19 revisions

Global object: Translator

The global Translator object allows access to the current configuration of the translator

Params:

  • enum preserveCaps whether capitals should be preserved by bracing then with {}. Values: none, all, inner
  • boolean fancyURLs set to true when BBT will generate \url{..} around the urls

class: Reference

The Bib(La)TeX references are generated by the Reference class. Before being comitted to the cache, you can add postscript code that can manipulated the fields or the referencetype

Params:

  • Array @fields Array of reference fields
  • String @referencetype referencetype
  • Object @item the current Zotero item being converted

The fields are objects with the following keys:

  • name: name of the Bib(La)TeX field
  • value: the value of the field
  • bibtex: the LaTeX-encoded value of the field
  • enc: the encoding to use for the field

clone(field, value)

Return a copy of the given field with a new value

Params:

  • field field to be cloned
  • value value to be assigned

Return:

  • Object copy of field settings with new value

enc_raw(field)

'Encode' to raw LaTeX value

Params:

  • field field to encode

Return:

  • String unmodified field.value

enc_url(field)

Encode to LaTeX url

Params:

  • field field to encode

Return:

  • String field.value encoded as verbatim LaTeX string (minimal escaping). If preference fancyURLs is on, wraps return value in \href{string}{string}

enc_verbatim(field)

Encode to verbatim LaTeX

Params:

  • field field to encode

Return:

  • String field.value encoded as verbatim LaTeX string (minimal escaping).

enc_creators(field)

Encode creators to author-style field

Params:

  • field field to encode. The 'value' must be an array of Zotero-serialized creator objects.

Return:

  • String field.value encoded as author-style value

enc_latex(field)

Encode text to LaTeX

This encoding supports simple HTML markup.

Params:

  • field field to encode.

Return:

  • String field.value encoded as author-style value

add(field)

Add a field to the reference field set

Params:

  • field field to add. 'name' must be set, and either 'value' or 'bibtex'. If you set 'bibtex', BBT will trust you and just use that as-is. If you set 'value', BBT will escape the value according the encoder passed in 'enc'; no 'enc' means 'enc_latex'. If you pass both 'bibtex' and 'latex', 'bibtex' takes precedence (and 'value' will be ignored)

remove(field)

Remove a field from the reference field set

Params:

  • name field to remove.

Return:

  • Object the removed field, if present
Clone this wiki locally