larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
219 stars 30 forks source link

Documentation for CSL Plugins incorrect? #192

Closed jcarpenter closed 2 years ago

jcarpenter commented 4 years ago

I think the CSL Plugins docs may need to change Cite.plugins.output.config.get('csl') to Cite.plugins.config.get('@csl')?

Similar to #161, I was getting undefined errors whenever I tried to call Cite.plugins.config.get. I was following the instructions in the CSL Plugins docs. After some struggling, I found Cite.plugins.list() under the plugins docs, used it, found that csl is actually @csl. I then tried to register my CSL template with Cite.plugins.config.get('@csl'), and found it worked.

Here's the full working code excerpt:

const references = fs.readFileSync('_input/citations/bib.json', 'utf8')

let cite = new Cite(references)

let stylesName = 'josh-csl'
let styles = fs.readFileSync('_input/citations/styles.csl', 'ascii')
Cite.plugins.config.get('@csl').templates.add(stylesName, styles)

var testCitation = cite.format('citation', {
    format: 'html',
    template: stylesName,
    lang: 'en-US',
    entry: ['wallace-wells2019']
})

console.log(testCitation)

citation-js@0.5.0-alpha.4, node v12.12.0, macOS 10.15

larsgw commented 4 years ago

I think the CSL Plugins docs may need to change Cite.plugins.output.config.get('csl') to Cite.plugins.config.get('@csl')?

True, I think the docs are changed locally but I forgot to build them.

After some struggling, I found Cite.plugins.list() under the plugins docs, used it, found that csl is actually @csl.

That's been bugging me too. I think I'll change it before v0.5.0.

leafac commented 4 years ago

I’ve been bitten by this as well.

By the way, this project is great! I’m very happy I’ve found it.

leafac commented 4 years ago

It seems that Cite.CSL.register.addTemplate() works as well.

ahtasham067 commented 2 years ago

Capture

ahtasham067 commented 2 years ago

i am facing this problem while using CSL plugin?

larsgw commented 2 years ago

How are you importing citation.js?

larsgw commented 2 years ago

Let's carry this on in https://github.com/larsgw/citation.js/issues/219 if you want.