Skip to content

Instantly share code, notes, and snippets.

@retorquere
Created February 5, 2024 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retorquere/b765166b9b280c08a25b13e94d3406ce to your computer and use it in GitHub Desktop.
Save retorquere/b765166b9b280c08a25b13e94d3406ce to your computer and use it in GitHub Desktop.
var CSL = require('citeproc')
var styleAsText = <contents of style.csl>
// Load your list of references
const references = {
item1: {
id: 'item1',
type: 'book',
title: 'Stuff',
},
}
// Create a CSL engine
var sys = {
retrieveLocale: function (lang) {
const locale = <contents of locale xml file>
return locale
},
retrieveItem: function (id) {
return references[id]
}
}
const citeproc = new CSL.Engine(sys, styleAsText)
// Specify the references to cite
citeproc.updateItems(Object.keys(references))
// Generate the bibliography
var bib = citeproc.makeBibliography()
dump(bib[1].join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment