sciunto-org / python-bibtexparser

Bibtex parser for Python 3
https://bibtexparser.readthedocs.io
MIT License
478 stars 132 forks source link

Convert parsed bibtex to plaintext #433

Open prady0t opened 10 months ago

prady0t commented 10 months ago

I'm currently working on a project that used pybtex for parsing bibtex file, but we want to switch to bibtexparser. Pybtex has a plugin to convert to plaintext (UTF-8). Example :

@article{Chen2020,
  author = {Chen, Chang-Hui and Brosa Planella, Ferran and O'Regan, Kieran and Gastol, Dominika and Widanage, W. Dhammika and Kendrick, Emma},
  title = {{Development of Experimental Techniques for Parameterization of Multi-scale Lithium-ion Battery Models}},
  journal = {Journal of The Electrochemical Society},
  volume = {167},
  number = {8},
  pages = {080534},
  year = {2020},
  publisher = {The Electrochemical Society},
  doi = {10.1149/1945-7111/ab9050},
}

gets converted to UTF-8 plaintext as:

Chang-Hui Chen, Ferran Brosa Planella, Kieran O’Regan, Dominika Gastol, W. Dhammika Widanage, and Emma Kendrick. "Development of Experimental Techniques for Parameterization of Multi-scale Lithium-ion Battery Models." Journal of the Electrochemical Society 167 (2020): 080534.

Since direct conversion is not possible in bibtexparser what measures can be taken to convert the parsed string to plaintext whose output remains as close to above as possible?

I would like to always print author, title etc in a specific order and independent of how it's written in .bib file itself.

MiWeiss commented 10 months ago

Hi @prady0t

Thanks a lot for your question. At the moment, a conversion to another representation is not supported.

I believe that especially your usecase is frequent enough to add it to the codebase, even if it's not really part of the core functionality of a bibtexparser.

I won't be able to implement this anytime soon though. If you'd be willing to open a PR with a well-tested version of such an exporter I'd be happy to review it though.