How to add a non-standard field to Citation-js CLS-JSON output

128 views Asked by At

I started using citation-js package and its plugins plugin-bibtex and plugin-csl with great satisfaction. Now I have one small problem:

I have a bibliography containing a non-standard field confsite. The entry is a InProceedings with url that points to the article and confsite that points to the conference site (I will ask how to cover this BibLaTex case). This field disappears in the CSL-JSON output.

Is there a way to retain any non-standard field in the new Cite(content) output?

Thanks!
mario

1

There are 1 answers

5
LarsW On

When Citation.js parses a BibTeX or BibLaTeX file, it is first turned into an array of objects as an intermediate step. You could perform this intermediate step explicitly to keep that array of objects, and then amend the CSL-JSON:

var bibtex = '...'
var bibtexJson = Cite.input(bibtex, { target: '@biblatex/entries+list' })
var cite = new Cite(bibtexJson)

for (var i = 0; i < cite.data.length; i++) {
  var entry = cite.data[i]
  if (typeof entry.custom !== 'object') {
    entry.custom = {}
  }
  entry.custom.confsite = bibtexJson[i].properties.confsite
}