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

Remember order of tags in BibTeX entry #28

Open
pjhuxford opened this issue May 31, 2024 · 2 comments
Open

Remember order of tags in BibTeX entry #28

pjhuxford opened this issue May 31, 2024 · 2 comments

Comments

@pjhuxford
Copy link

Currently the tags of a bibliography entry are stored in a HashMap, which means the order of the tags is unstable.

I have a use-case in mind where I would like to parse a bibliography entry from a file, perform some minor edits, and then write the new entry back to the same file. If I use nom-bibtex for the parsing then I have no way to recover the original order of the tags in the entry. This could potentially make the version control history of the file confusing to decipher.

If you're also interested in remembering the order of the tags, I suppose one option would be to replace HashMap with IndexMap from the indexmap crate. Another option would be storing a Vec<String> of the keys alongside the HashMap.

@A6GibKm
Copy link
Contributor

A6GibKm commented May 31, 2024

Makes sense to me, but returning a struct thats not from the lib, nor from std is kinda annoying.

@pjhuxford
Copy link
Author

Yeah it is annoying that IndexMap isn't in std, although it does seem like the most performant way to handle this. Maybe storing the keys of the tags in a Vec<String> is a better approach though. What do you think?

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