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
222 stars 30 forks source link

Fix of bibtex with multiline authors #158

Closed me2d09 closed 5 years ago

me2d09 commented 6 years ago

When parsing bibtexfile with authors on more than one line, it produces: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of object at _iterableToArrayLimit. This change fixes the issue.

Example input:

@ARTICLE{ToftPetersen:810264, author = {Toft-Petersen, Rasmus and Groitl, Felix and Kure, Mathias and Lim, Joshua and Čermák, Petr and Alimov, Svyatoslav
and Wilpert, Thomas and Le, Manh Duc and Quintero-Castro, Diana and Niedermayer, Christof and Schneidewind, Astrid and Habicht, Klaus}, title = {{E}xperimental characterization of a prototype secondary spectrometer for vertically scattering multiple energy analysis at cold-neutron triple axis spectrometers}, journal = {Nuclear instruments $\&$ methods in physics research / A}, volume = {830}, reportid = {FZJ-2016-03124}, pages = {338 - 344}, year = {2016}, doi = {10.1016/j.nima.2016.06.004}, url = {http://juser.fz-juelich.de/record/810264}, }

larsgw commented 6 years ago

I assume this should apply to every field, including for example the title in your example? If so, I think it would be better to put this here:

https://github.com/larsgw/citation.js/blob/a7af38a2895ae85afc967cb21ce03671ee5f59d9/src/parse/modules/bibtex/text.js#L145

Also, I believe this doesn't catch single newlines, so /\s+/g would be better.

larsgw commented 5 years ago

Slightly different version added in https://github.com/citation-js/citation-js/commit/3f081bc5c1d930f966187466ae02a52c6b77a42a