jwcarr / bibfish

Extract entries from a .bib file that are cited in a .tex file
MIT License
23 stars 5 forks source link

Handling abbreviations #8

Open nancyday opened 10 months ago

nancyday commented 10 months ago

bibfish seems to be just what I am looking for but it doesn't handle abbreviations such as:

journal = cacm

where cacm is defined in a separate bib file as:

@string{cacm = "Comm.\ of the ACM"}

I want to keep the abbreviations in the bib entries in the output file.

jwcarr commented 9 months ago

Hi! If I understand correctly you would like strings to not be interpolated in the output file. Currently, strings are interpolated automatically by Bibtexparser (see line 82 in __init__.py).

We could potentially introduce a command line flag, e.g. --do_not_interpolate_strings – this would be pretty straight-forward.

However, you mention also wanting to have the strings defined in a separate file. I assume, then, that you are using -b to supply the additional bib files containing the string definitions? Handling this case would be more complicated because currently each bib file is parsed independently and then merged into a single database (see function parse_bibtex_entries()). Thus, your use case results in an error being raised because the main bib file cannot be parsed without the strings.

Have I understood your use case correctly? If so, I suspect we'd need to modify the parsing approach, which may or may not be straight-forward – I'm not sure. For example, the bib files could first be concatenated and then parsed, but I can also foresee this raising some other issues – notably the order in which the files are specified/concatenated. Possibly @rbeyer might have some ideas here?

rbeyer commented 9 months ago

I'm guessing that they want Bibfish to produce an output .bib file where the @strings are not expanded, and then in their usage they'll use that Bibfish-output .bib file and another with the @string definitions maybe (if they've kept things clean and separate), and in that case your suggestion of a command-line flag should address that use-case and might be straightforward?

Maybe you're concerned about the @string definitions begin salted in amongst the source .bib files and then having to manage them somehow into a bibfish output? Yeah, that would be more bookkeeping. Maybe if we had a a better idea of the use case from @nancyday (what the input files might look like, what the final outcome might be, more detail on the workflow that you'd like to see enabled, etc.) then it might be easier to scope the solution.

nancyday commented 9 months ago

My use case is that I would like "the strings to not be interpolated in the output file" :-) If something is parsed as a string on input, I would like it output as the same string. (I then use the output bib file with a separate bib file that has the definitions of the strings). Thanks!