0

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

SiliconValley
  • 1,465
  • 17
  • 30

1 Answers1

0

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
}
LarsW
  • 1,514
  • 1
  • 13
  • 25
  • Unfortunately `"Cite.input is not a function"` error. Maybe I missed something obvious – SiliconValley May 31 '23 at 11:29
  • Seems the solution is to delete the Cite.input line and put `{target:...` on the `new Cite` call. Thanks! – SiliconValley May 31 '23 at 11:34
  • Thanks LarsW! Here my solution (maybe not the most efficient one): `const bibtexJson = new Cite(content, {target: "@biblatex/entries+list"}); cite = new Cite(content);` then your for loop. But it works. Thanks a lot! – SiliconValley May 31 '23 at 13:30
  • Whether `Cite.input()` exists depends on whether you're importing `@citation-js/core`, or importing the deprecated wrapper `citation-js`. From your question I assumed the latter but that may have been wrong. – LarsW Jun 01 '23 at 13:24
  • No, I import /core – SiliconValley Jun 03 '23 at 06:55