-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting bibliography #220
Comments
The bibtex.format('data', {
format: 'object', // 'object' for a JS Object, 'text' for a JSON string
entry: Array.from(allEntries),
}) |
Thanks! Is there a way to get the bibliography items sorted appropriately? Getting Use case: I'm trying to customize the formatting function (add links etc.) Right now |
Not directly but something like this should work to get a sorted list of IDs: // Format entries normally but with the asEntryArray option
const formattedEntries = bibtex.format('bibliography', {
format: 'html',
template: 'apa', // not citation-apa btw
entry: Array.from(allEntries),
asEntryArray: true,
})
// Get sorted ids from sorted entries
const sortedIds = formattedEntries.map(function () {
// entry[0] is the id, entry[1] is the formatted entry
return entry[0]
})
// Look up the original entries
const data = bibtex.format('data', { type: 'object' }) // (or bibtex.data but then you miss some processing)
const dataById = data.reduce((ids, entry) => { ids[entry.id] = entry }, {})
const sortedData = sortedIds.map(id => dataById[id])
There is some interest among the CSL and citeproc-js maintainers to make those things possible but nobody has started to implement it. There is a way to do something similar, a development mode made for https://editor.citationstyles.org/visualEditor/ I think but when I looked at it last time it seemed insufficient. But I will check again, it would be very useful. |
I have a Cite object
bibtex
and would like to format the bibliography myself.This works:
For
format
field,html
andtext
work. However, when I tried other formats (e.g.object
,json
) I get the following error:The text was updated successfully, but these errors were encountered: