inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

multiple .bib files with duplicate entries #266

Closed jennhu closed 4 years ago

jennhu commented 5 years ago

Is there a way to use multiple bibliography files that may contain duplicate entries, without rendering the duplicates? e.g.

{% bibliography --file pubs1.bib --file pubs2.bib %}

but not rendering the entries in pubs2.bib that are also present in pubs1.bib (e.g. by matching the key or matching all fields).

Thanks!

inukshuk commented 5 years ago

Unfortunately not currently, no.

I think it would be fairly easy to add a switch to ignore entries with duplicate keys regardless of whether or not --file or * for the bibliography setting is used. I think we would just have to filter out those duplicates right after compiling the bibliography object around here.

rseac commented 4 years ago

@inukshuk It seems that multiple bibs with the same key get added into the bibliography database with different keys. Is that intended? If so, would a duplicate require matching all fields of an entry other than the key?

      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }

      @book{ruby,
        title     = {Smalltalk Best Practice Patterns},
        author    = {Kent Beck},
        year      = {1996},
        publisher = {Prentice Hall}

Ends up being as follows. Note the key rubz

@book{ruby,
  title = {The Ruby Programming Language},
  author = {Flanagan, David and Matsumoto, Yukihiro},
  year = {2008},
  publisher = {O'Reilly Media}
}
@book{rubz,
  title = {Smalltalk Best Practice Patterns},
  author = {Beck, Kent},
  year = {1996},
  publisher = {Prentice Hall}
}
inukshuk commented 4 years ago

I just realized that we already support detecting duplicates (by content of each field in bibtex-ruby). See here for more

It would be easy to call uniq! on the bibliography object.

As for disambiguating the keys, yes, it seems we also implemented this in bibtex-ruby: this code is called when an entry is added to a bibliography object and the key may get changed here. The way this looks there is no easy way to turn this off. We'd have to add an option to bibtex-ruby to chose between disambiguate, overwrite, skip. Then we could pass that option down from jekyll-scholar with the other bibtex options.

rseac commented 4 years ago

@inukshuk can this be closed?

inukshuk commented 4 years ago

Yes!