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

Replace the bibparse backend of 'g:vimtex_parser_bib_backend' with GooseBib #2103

Closed
krishnakumarg1984 opened this issue Jul 13, 2021 · 13 comments

Comments

@krishnakumarg1984
Copy link
Contributor

bibparse is one of the options that can be set for g:vimtex_parser_bib_backend. Firstly, the documentation was missing the URL or other background information about bibparse for those who have never heard of this before. But that is quickly addressed with some basic web searching :).

Secondy, and more seriously, it looks like bibparse itself is deprecated in favour of Goosebib. Quite ominously, the README.md ominously warns: In time this respository will be removed.

It looks like it would be prudent to include Goosebib as one of the options for g:vimtex_parser_bib_backend, along with a documentation update to point users to the relevant Github URL. Also, some pointers to set this conditionally would be nice I think, i.e. something along the lines of:

if executable('GbibParse')
let g:vimtex_parser_bib_backend='Gbibparse'
endif

Finally, it also looks like the host of tools provided by the Goosebib suite looks like a useful way to fix/clean/slice/dice bib files. I think this tool can be mentioned in the Filetype plugin for bib files section early in the documentation, wherein useful tools like bibtool are mentioned. Also for posterity, I am updating #1293 with Goosebib since this issue is also linked to from the documentation, making it easier for new readers to refer to a centralised place for bib tools.

@lervag
Copy link
Owner

lervag commented Aug 15, 2021

Interesting! An issue here is that GooseBib does not give a simple output to parse; GbibParse input.bib output.bib outputs a cleaned up bibtex file, still in fully bibtex format. Thus, the parsing remains. The "benefit" of bibparse was that it outputted a much easier format where it was trivial to parse it. Essentially, it seems GooseBib does not give any benefits over internal parsing within vimtex. Thus, I don't see a good reason to support it.

However, it might be necessary to drop support for bibparse in the future, if it is fully removed. :\

@lervag
Copy link
Owner

lervag commented Aug 15, 2021

But: Perhaps a better idea is to use directly the bibtexparser library!

lervag added a commit that referenced this issue Aug 15, 2021
@lervag
Copy link
Owner

lervag commented Aug 15, 2021

Ok, I've added bibtexparser as a new backend and updated the docs. However, for some reason, bibtexparser is not very fast. I assume it is not so strange, as Python is not really so fast. I guess bibparse, which uses bibtexparser, is fast because it is compiled or something like that. I don't know.

Do you have any thoughts?

@lervag lervag closed this as completed Aug 15, 2021
@lervag
Copy link
Owner

lervag commented Aug 16, 2021

Hah! I just noticed (and now remember) that bibparse is not the Python implementation. There's a name confusion here. bibparse comes from Text-BibTeX, a perl package. For some reason, installing this does not provide the bibparse executable on all systems. On Arch Linux, if you install perl-text-bibtex, you will get the bibparse executable. Since this parser is written in C, it is very fast. FYI, the bibtexparser parser which is used by the Python projects bibparse and GooseBib is very slow, even slower than the internal parser I've written in vimscript.

In any case, I've made things more clear in the docs and I've added support for the bibtexparser python library now, which at least gives more options.

@krishnakumarg1984
Copy link
Contributor Author

Most of the stuff you mentioned flew over my head, but I could understand things better through your latest docs update. Thanks a lot for looking into this Karl!

@krishnakumarg1984
Copy link
Contributor Author

Would this syntax be correct (for portability of a common .vimrc between machines with & without the bibparse perl library)?

if executable('bibParse')
       let g:vimtex_parser_bib_backend='bibparse'
endif

@lervag
Copy link
Owner

lervag commented Aug 17, 2021

Would this syntax be correct (for portability of a common .vimrc between machines with & without the bibparse perl library)?

Almost! The executable string should be lower case, I believe: executable('bibparse').

@krishnakumarg1984
Copy link
Contributor Author

Thank you. This could perhaps be mentioned in the docs, like how you have provided conditional checks for setting up various other functionality (e.g. the documentation handlers).

lervag added a commit that referenced this issue Oct 16, 2022
@lervag
Copy link
Owner

lervag commented Oct 16, 2022

Agreed.

@krishnakumarg1984
Copy link
Contributor Author

So, this bibparse executable comes from where? From the goodebib package?

@lervag
Copy link
Owner

lervag commented Oct 18, 2022

This is what I wrote in the docs (:help g:vimtex_parser_bib_backend):

    `bibparse`: Also fast, but might be more robust.

              Note: bibparse is an executable provided by the Perl package
                    Text-BibTeX [0]. It should not be confused with the
                    similarly named Python project [1]. The latter is
                    deprecated in favor of GooseBib [2]. The Python projects
                    bibparse and GooseBib are both based on the Python library
                    `bibtexparser`.

                    [0]: https://metacpan.org/dist/Text-BibTeX
                    [1]: https://github.com/tdegeus/bibparse
                    [2]: https://github.com/tdegeus/GooseBib

@krishnakumarg1984
Copy link
Contributor Author

krishnakumarg1984 commented Oct 30, 2022

@lervag https://metacpan.org/dist/Text-BibTeX does not seem to be updated for over 3 years. For a non-perl user like me, it is not clear how to install such perl packages, and make them available in $PATH. Could you please expand on such details in the documentation?

For the famous python-based parser (https://github.com/sciunto-org/python-bibtexparser) that underpins a lot of pythonic bib tools, it is getting a major speed boostup in the upcoming 2.0 release. https://github.com/sciunto-org/python-bibtexparser#id5 . Perhaps worth keeping an eye out for this for vimtex's adoption.

Also, FWIW, there's a very good rust crate https://github.com/typst/biblatex that is an amazing parser.

@lervag
Copy link
Owner

lervag commented Oct 30, 2022

@lervag https://metacpan.org/dist/Text-BibTeX does not seem to be updated for over 3 years.

Well, that doesn't mean much, except that it is mature and works as expected?

For a non-perl user like me, it is not clear how to install such perl packages, and make them available in $PATH. Could you please expand on such details in the documentation?

I'm not really very experienced in the ways of Perl myself either, so I'm not sure what to write. For Arch Linux, you can install it with pacman -S perl-text-bibtex. Not sure how to install it in other systems.

For the famous python-based parser (https://github.com/sciunto-org/python-bibtexparser) that underpins a lot of pythonic bib tools, it is getting a major speed boostup in the upcoming 2.0 release. https://github.com/sciunto-org/python-bibtexparser#id5 . Perhaps worth keeping an eye out for this for vimtex's adoption.

Also, FWIW, there's a very good rust crate https://github.com/typst/biblatex that is an amazing parser.

I would not mind adding support for more parsers, but it would be nice to get that as separate feature requests with good links - preferably with simple explanations on how to install and use the parsers.

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