charlesvdv / nom-bibtex

A feature complete bibtex parser using nom
https://docs.rs/nom-bibtex
MIT License
24 stars 15 forks source link

Supporting non-numeric values in month field #26

Open hertg opened 9 months ago

hertg commented 9 months ago

[!NOTE] This issue was originally posted in getzola/zola#2367

Issue

When loading a BibTeX file that has a non-numeric month field, the parsing fails. Using a three letter abbreviation for the month seems to be at least somewhat common practice.

Here is a BibTeX as provided by the IETF for an RFC (https://datatracker.ietf.org/doc/rfc6749/bibtex/)

@misc{rfc6749,
    series =    {Request for Comments},
    number =    6749,
    howpublished =  {RFC 6749},
    publisher = {RFC Editor},
    doi =       {10.17487/RFC6749},
    url =       {https://www.rfc-editor.org/info/rfc6749},
    author =    {Dick Hardt},
    title =     {{The OAuth 2.0 Authorization Framework}},
    pagetotal = 76,
    year =      2012,
    month =     oct,
    abstract =  {The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf. This specification replaces and obsoletes the OAuth 1.0 protocol described in RFC 5849. {[}STANDARDS-TRACK{]}},
}

Workaround

My current workaround is to either manually change the month to its numerical representation (i.e. month = 10 instead of month = oct), or to add the following lines at the top of my bibtex file:

@string (jan="1")
@string (feb="2")
@string (mar="3")
@string (apr="4")
@string (may="5")
@string (jun="6")
@string (jul="7")
@string (aug="8")
@string (sep="9")
@string (oct="10")
@string (nov="11")
@string (dec="12")