yepengding / bibtex-js-parser

A BitTeX parser implemented in JavaScript (ES6). Transforming a BibTeX file to an object in memory or a semi-structured file on disk.
MIT License
4 stars 0 forks source link

BibTeX Entries without Trailing Commas #2

Open cmj2002 opened 11 months ago

cmj2002 commented 11 months ago

The BibTeX standard does not explicitly require the last entry to end with a comma. Moreover, example from Wikipedia and automatically generated BibTeX from Google Scholar do not include a comma at the end of the last entry.

While bibtex-js-parser currently handles entries without trailing commas correctly and produces the expected output, it also prints a warning in the console for such cases.

Take the example in the README, if we remove the comma at the end of the last entry, it would be:

@inproceedings{ding_dagbase_2020,
    title = {Dagbase: a decentralized database platform {Using} {DAG}-based consensus},
    copyright = {All rights reserved},
    isbn = {1-72817-303-5},
    booktitle = {2020 {IEEE} 44th {Annual} {Computers}, {Software}, and {Applications} {Conference} ({COMPSAC})},
    publisher = {IEEE},
    author = {Ding, Yepeng and Sato, Hiroyuki},
    year = {2020},
    pages = {798--807}
}

@article{ding_formalism-driven_2022,
    title = {Formalism-{Driven} {Development}: {Concepts}, {Taxonomy}, and {Practice}},
    volume = {12},
    copyright = {All rights reserved},
    issn = {2076-3417},
    url = {https://www.mdpi.com/2076-3417/12/7/3415},
    doi = {10.3390/app12073415},
    number = {7},
    journal = {Applied Sciences},
    author = {Ding, Yepeng and Sato, Hiroyuki},
    year = {2022}
}

This would cause two warnings:

line 10:0 missing ',' at '}'
line 23:0 missing ',' at '}'

I suggest changing the program's behavior to make it more tolerant of entries without trailing commas, eliminating the warning from the console output. This adjustment would align the program with common BibTeX practices and user expectations.

In addition, the warning printed to the console does not indicate that it is from bibtex-js-parser. It would be more helpful for users to debug if the warning message can indicate its source (for example, print bibtex-js-parser: line 10:0 missing ',' at '}'). I spent a lot of time looking for where the warning comes from.

yepengding commented 11 months ago

Thank you for reporting this issue. The recent patch (0417cae) of the grammar project has addressed it. I have also scheduled the update for both JS and Java parsers. Your patience would be appreciated.