Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BibTeX: load_data fails on non-numeric values in the "month" field #2367

Closed
hertg opened this issue Dec 9, 2023 · 5 comments
Closed

BibTeX: load_data fails on non-numeric values in the "month" field #2367

hertg opened this issue Dec 9, 2023 · 5 comments

Comments

@hertg
Copy link

hertg commented Dec 9, 2023

Bug Report

When loading a BibTeX file that has a non-numeric month field, the parsing fails.

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{]}},
}

Using this BibTeX will lead to the build failing. My current workaround is to manually change
the month to its numerical representation (i.e. month = 10 instead of month = oct).

Environment

Zola version: 0.17.2

Expected Behavior

The month field should be parsable, even if it is a three letter abbreviation, which seems to be somewhat common practice.

Current Behavior

Build fails with the following error.

Error: Failed to build the site
Error: Failed to render page '/some/path/content/posts/2023-12-10/index.md'
Error: Reason: Failed to render 'page-template.html'
Error: Reason: Function call 'load_data' failed
Error: Reason: StringVariableNotFound("oct")

Step to reproduce

Create a file references.bib:

@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{]}},
}

Attempt to load the file in a template:

{% set references = load_data(path="path/to/references.bib", format="bibtex") %}
@hertg
Copy link
Author

hertg commented Dec 9, 2023

Just saw that you are using charlesvdv/nom-bibtex under the hood. Please let me know if I should re-open this issue over there. :)

@hertg
Copy link
Author

hertg commented Dec 10, 2023

Another workaround, instead of manually adjusting the bibliographies, adding the following to the top of the BibTeX file will also work:

@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")

@Keats
Copy link
Collaborator

Keats commented Dec 10, 2023

Upstream is definitely better

@hertg
Copy link
Author

hertg commented Jan 2, 2024

I opened an issue upstream: charlesvdv/nom-bibtex#26
I'll leave it up to you whether you want to close it or keep it open here. Thanks.

@Keats
Copy link
Collaborator

Keats commented Jan 2, 2024

Let's close but do comment here if it gets resolved

@Keats Keats closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants