Closed Galadirith closed 6 years ago
Thanks for the bug report! I'm glad you find the package useful.
I made my own JSON serialisation function to be able to output HTML-formatted JSON. I don't know if there's a use case for that, but I included it anyway. That was probably a bad idea on my end, mainly because I know don't support JSON (not really, that is). I'll see what causes the issue and publish a fix when I can. Until then, you could create a script that serialises the data directly, i.e.:
var Cite = require('citation-js')
var data = new Cite(input)
var output = JSON.stringify(data.data)
// optionally JSON.stringify(data.data, null, 2) for nicer formatting
// '[{...}, {...}]'
I'll also look at replacing this functionality with something more sensible. For updates on that, see #144.
@larsgw Thanks so much for the reply, I really appreciate it.
The solution worked great, thanks so much for finding one so quick.
I tried a few packages to do this conversion and citation-js
was by far the easiest to use, and also the most reliable convertor (with others dropping fields that should have been converted, or mangling fields etc). Even though the solution here is not on the command line, wrapping that in a script is simple enough and it's still the simplest solution :blush:
If there's a fix for this in the future that would be amazing, but I also completely appreciate that this is one of the more periphery features, so certainly no rush and if it's never fixed there is a working solution https://github.com/larsgw/citation.js/issues/143#issuecomment-388486047 👍
I'd be happy to close this in favour of #144 but I'll leave it for you in case you wanted this left open for reference.
No problem! I added a commit that should fix this issue to master, but a new release might take some time, while I'm shifting around methods and namespaces.
What version of Citation.js are you using?
citation-js@v0.4.0-1
What version of Node and what OS are you using?
node@v10.1.0
anddebian@jessie
through the official docker node image running on OS X 10.11.6 (El Capitan)What did you do? (this includes input data, configuration, etc.)
What did you expect to see? Conversion of the two bibtex entries to a valid csl-json file.
What actually happened? An almost valid csl-json file, but with an extra
,
separating the two elements of the output jsonI expected
the full output is below
Attempting to import this via
JSON.parse(...)
fails. If you have more bibtex entries you get an extra comma between every paid of output items. For a single bibtex entry you get valid json output.Thanks so much for an amazing package @larsgw :blush: 👍