msprev / fzf-bibtex

a BibTeX source for fzf
BSD 3-Clause "New" or "Revised" License
129 stars 15 forks source link

[feature request] Run latexpand on bib file #32

Closed folofjc closed 2 years ago

folofjc commented 2 years ago

My bib file has lots of things that bibtool does not like. I use comment lines so I can fold in vim, etc. I know, not ideal.

Luckily, latexpand can easily remove all this. It would be great if fzf-bibtex could have an option to run latexpand on the Bib files and store them in the cache directory. Just an option, not by default.

I know I could do this myself and it isn't a huge deal, but I would have to do it everytime I change the bib file, which is not ideal.

folofjc commented 2 years ago

I guess it could be added as an option to run here?

msprev commented 2 years ago

I don't want to add another dependency unless there is a very strong reason to do so. Can you explain exactly what the issue is that is causing the bibtool parsing to fail?

bibtool is extremely powerful, flexible and stable. To my mind, it functions as a very useful and robust standard for what counts as a valid bibtex file. I'm extremely reluctant to allow parsing of bibtex files that bibtool would reject -- that way lies madness. However, bibtool has lots of options for ignoring stuff, so perhaps your case can be accommodated by it if you explain what the issue is.

folofjc commented 2 years ago

I have had the same problem with trying to use pandoc with a bib file that has "extra" things in it.

If you have a comment in your entry somewhere, bibtool simply rejects it. latexpand is nice because it will remove all these comments.

I agree that my case means that I have a bib file that bibtool will not parse, and therefore it is my fault. (I think it is also bibtool's fault, because something like biber has no problems with by bib file when actually compiling LaTeX, so I do not agree that my bib file is "wrong".) What I normally do for pandoc is that I have a makefile that runs latexpand, but for vim I don't have this option.

What I could so is to have one ENV var that has my bib file, and then in my vimrc I can make it so that it runs latexpand on it and stores it in the ENV dir that fzf-bibtex uses. I was just hoping to avoid this step since fzf-bibtex has a cache dir already, so I wouldn't have other files lying around.

msprev commented 2 years ago

There is no universal standard for what counts as valid/invalid bibtex, so 'right' and 'wrong' are all relative here. That is part of what makes it a nightmare to parse bibtex, and why I choose a robust and long-standing tool like 'bibtool' to set the standard.

If I were you, I would do something like what you suggest at the end of your post -- have an autocommand or watchfile so that when you update your bibtex file it automatically creates a clean version that fzf-bibtex can read.