Trailing comma in entries
kaustubhmote opened this issue · 4 comments
A trailing comma should be for the last item in an entry, for example:
@Article{Einstein1905,
author = {Einstein A},
...
year = {2010}, <---
}
This can be done by changing pybibs/_internals.py:120
to parts.append(",\n}")
.
Will be happy to submit a PR if this is something you would like to do.
Do you mean that you expect bibo to write trailing commas, or is there an issue with parsing them? According to the BibTeX Format Description:
Tags are separated by commas; if not, the BibTeX parser will produce an error. The last tag can be finished with a comma, although not necessarily.
I have no strong preference either way.
@Kappers, would love to hear your thoughts about this.
Sorry, I should have explained better.
The trailing commas are not required in the .bib file, and there is no issue with parsing.
However, trailing commas have some advantages, listed nicely in this blog. Also this from the black project. All of this is for code of course, but similar concerns apply to the .bib file when it is kept in a git repo, as I suspect many do. I also keep adding things like tags, keywords, groups etc, other non-bibtex parameters to the bib entries, and I have in past run into parsing issues when the trailing comma is absent.
Thanks for the clarification, and there's nothing to be sorry about :-)
I always prefer trailing commas in code, because of version control. I don't use version control for my bibliography, and therefore no diffs, so I don't have a preference here. But obviously there's a strong case to output trailing commas for whoever want to diff their .bib file, so let's go for it!
Looking forwards to the PR.
Great,
I guess I noticed this since I am using git for the .bib file as well (and got ~3500 diff lines after adding a single new entry!)
Anyways, the change is small, but it seems to affect a test. So I'll modify the test accordingly.