-
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
Year missing from output #52
Comments
Hmmm. Weird. It does parse the date and puts it in the CSL-JSON: [
{
"author": [
{
"given": "Happy",
"family": "Larry"
}
],
"issued": [
{
"date-parts": [
2017,
1,
1
]
}
],
"title": "A Lovely Title",
"type": "article-journal",
"label": "id",
"id": "id"
}
] Reading the style source from citationstyles.org, it should pick it up too, but it doesn't. I'll look into it further. About the demo page: I always assumed it was omitted because of the specific style. |
Yep I noticed that on the embedded RunKit demo at citation.js.org. I've spent a lot of today reading about CSL and trying different styles and bibtex layouts 😅 I've even tried brutally injecting .issued.date-parts into the Cite object but that didn't work. Hence I wondered if it was (a) my misunderstanding or (b) a bug. |
Feel free to also report other problems here (I saw quite a few "Citation.js this & that"s in your code), I'm happy to help! For example, not supporting non-builtin locales is a pretty serious issue. I'm working on a feature right now that should make it much easier to work with "custom" templates and different locales. See (if you want) #40. This should also solve the |
As I expected after looking through some code, the root of the problem is citeproc-js (unless I got something wrong): require('isomorphic-fetch')
const CSL = require('citeproc')
const lang = 'en-GB'
const json = [
{
"author": [
{
"given": "Happy",
"family": "Larry"
}
],
"issued": [
{
"date-parts": [
2017,
1,
1
]
}
],
"title": "A Lovely Title",
"type": "article-journal",
"label": "id",
"id": "id"
}
]
const template = await (await fetch('https://cdn.rawgit.com/citation-style-language/styles/master/apa.csl')).text()
const enGB = await (await fetch('https://cdn.rawgit.com/citation-style-language/locales/master/locales-en-GB.xml')).text()
const enUS = await (await fetch('https://cdn.rawgit.com/citation-style-language/locales/master/locales-en-US.xml')).text()
const locales = {'en-GB': enGB, 'en-US': enUS}
const retrieveLocale = lang => locales[lang]
const retrieveItem = id => json.find(item => item.id === id)
const engine = new CSL.Engine({
retrieveItem,
retrieveLocale
}, template, lang, true)
engine.updateItems(['id'])
engine.makeBibliography() gives, after assembling: <div class="csl-bib-body">
<div class="csl-entry">Larry, H. A Lovely Title.</div>
</div> https://runkit.com/larsgw/citation-js-issue-52-2/1.0.0 While reading some citeproc-js source code, I came across this line:
Which seems to suggest the citeproc-js date format is closer to the CSL-JSON specification than to the citeproc-js docs (see Juris-M/citeproc-js#48). However, when changing the date to that format, the output changes to (omitting HTML):
Where |
ConclusionThe issue is a miscommunication between citeproc-js and citation.js, caused by inaccurate citeproc-js docs (see Juris-M/citeproc-js#48). I'll fix it after completing #40 to avoid git merging problems. |
Thanks @larsgw , really appreciate this; n.d. is indeed "no date", any other similar placeholder might be inserted by the CSL. Comments in my code are absolutely no reflection on citation-js, only a reflection of the kind of day I was having at the time 😉 Very pleased to have found citation-js, it will make writing lengthy essays far easier. |
I made a general issue (#53) about dates not working currently, so I think I'll close this one. I'll post another message in this thread when it is fixed. |
Fixed. I'll post the note here too:
|
Hi there! I met a similar problem exactly as the the title of this issue, but slightly different(maybe) var bibtex =
`@article{10.1126/science.290.5496.1555,
year = {2000},
title = {{Powering an Inorganic Nanodevice with a Biomolecular Motor}},
author = {Soong, Ricky K. and Bachand, George D. and Neves, Hercules P. and Olkhovets, Anatoli G. and Craighead, Harold G. and Montemagno, Carlo D.},
journal = {Science},
issn = {0036-8075},
doi = {10.1126/science.290.5496.1555},
pmid = {11090349},
pages = {1555--1558},
number = {5496},
volume = {290},
keywords = {}
}`
const metaData = new Cite(bibtex);
console.log(metaData.format('data', {
format: 'object',
}))
the 'year' field is missing somehow |
When you run your code like this, Citation.js actually converts the BibTeX file to the CSL-JSON format, and the CSL-JSON format actually represents dates differently. The
And also when I format it as APA HTML:
If you want to get a JSON representation of the BibTeX file without converting it to a different format, you can do the following: Cite.plugins.input.chain(bibtex, {
target: '@biblatex/entries+list'
}) results in [ { type: 'article',
label: '10.1126/science.290.5496.1555',
properties:
{ year: '2000',
title:
'{Powering an Inorganic Nanodevice with a Biomolecular Motor}',
author:
'Soong, Ricky K. and Bachand, George D. and Neves, Hercules P. and Olkhovets, Anatoli G. and Craighead, Harold G. and Montemagno, Carlo D.',
journal: 'Science',
issn: '0036-8075',
doi: '10.1126/science.290.5496.1555',
pmid: '11090349',
pages: '1555--1558',
number: '5496',
volume: '290',
keywords: '' } } ] Fields like Note that this parses it as BibLaTeX (same as what you are doing at the moment), which is mostly backwards-compatible with regular BibTeX. If you want to parse it strictly as BibTeX, try the following: Cite.plugins.input.chain(bibtex, {
forceType: '@bibtex/text',
target: '@bibtex/entries+list'
}) You can view the documentation of the parsing options ( |
@larsgw |
Hi there. Is there a bug which prevents the year being included in output when rendering bibtex to HTML under node?
I notice the year is missing from the output on the demo page.
I've tried several chunks of bibtex and several CSL styles, all to no avail.
Here's a demo:
test.js:
Output:
The text was updated successfully, but these errors were encountered: