Closed jczerwinski closed 5 years ago
For google's sake, the error message is:
TypeError: Cannot read property 'get' of undefined
I'm using "citation-js": "^0.4.0-9"
Looks like this is the new API:
Citation.CSL.register.addTemplate(citation_style_name, citation_stylesheet);
No, that's the old API. The docs contain a typo, it should simply be Cite.plugins.config.get('csl')
. Sorry for the confusion.
No worries, and thanks for your help. I still can't seem to get it working, unfortunately.
Neither of the above methods for registering a style throw an error; however, when I try to format a citation or bibliography using said style, it doesn't seem to work, and just silently defaults back to apa
. The built in styles do all work, though.
Can you confirm that this is the intended API workflow?
Cite.plugins.config.get('csl').templates.add('ieee', ieee_stylesheet);
let bibliography = new Cite();
bibliography.add(...);
bibliography.format('bibliography', {
format: 'html',
template: 'ieee'
});
That should work. Only thing is that you can also pass items in the Cite
constructor. As for the reason it doesn't work (I can't reproduce it so far), can you run this after adding ieee
:
Object.keys(Cite.plugins.config.get('csl').templates.data)
console.log(Object.keys(Cite.plugins.config.get('csl').templates.data))
> [ 'apa', 'vancouver', 'harvard1', 'ieee' ]
Still not working though.
I'm going to keep digging. It looks like it might have something to do with engines.js grabbing a fresh copy of the style registry, rather than using the updated one?
Or alternatively, bibliography.js grabbing a new engine, rather than the existing one?
Nevermind, I think it's on me. Async things happening in unexpected order in my code. Thanks!
I'm trying to import a new CSL style.
According to the docs (https://citation.js.org/api/tutorial-output_plugins_csl.html), we should be able to do:
But
Cite.plugins.output.config
is undefined :(Did the API change and the docs are just out of date? Or something else?
Cheers!