Skip to content

Conversation

@mueller-physics
Copy link

Great library! Ran into some small problems setting it up, pull request has the fixes I've implemented.

@pcooksey pcooksey self-assigned this May 15, 2019
@pcooksey
Copy link
Owner

Thanks for using my library! I like to create test-cases before committing code to the repo to help ensure bugs don't come back. Do you have an example of the endless loop (like a bibtex file or entry that causes it)?

@mueller-physics
Copy link
Author

Thanks for the library, it makes my life much easier maintaining a literature list online.

The problem I ran into, as I realized now, was actually caused by a malformatted bibtex file on my side. More specifically, if a comma is missing between entries, e.g. author={someone}, year={2019} vol={1} instead of correctly author={someone}, year={2019}, vol={1} the code would go into an endless loop. If I understand the parser correctly, on a properly formatted file it just correctly matches the comma and everything works fine, but on a broken file it endlessly loops looking for a closing ")", as that does not have an 'only when it exists' condition around it.

With the fix, even a malformatted entry will be parsed, but any property after the missing "," won't make it into the parsed version of the dataset. I am not sure if either behaviour (endless loop vs. silently not parsing the whole entry) is more preferable.

@pcooksey
Copy link
Owner

You're welcome. I'm glad it helps.

Thank you for the explanation and example. I was trying to figure out why it would endlessly loop but I was assuming the bib entry was formatted correctly. An improperly formatted bib file would definitely cause problems.

I think the best option is to trigger an error and hopefully an error that can show the user where the formatting problem is in the bib file. I've been needing to look at better error detection rather than failing silently or looping endlessly. I'll also look into the other two changes you made which seem more like formatting changes.

@pcooksey
Copy link
Owner

Did you happen to look at the console output of your web browser when had the malformed bibtex entry or when you thought the program was endlessly looping?

For example when I test the example below (missing comma):

@book{entry2,
      author={First Last},
      year={2019}
      vol={1}
      }

I get the error below which points to the issue followed by the rest of the bibtex file:

Uncaught Token mismatch, expected ), found vol={1}
      }
      @book{entry3,
      author = {First Last},
      year={2019},
      title = {Title}
      }

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

Successfully merging this pull request may close these issues.

2 participants