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

Add support for multiple bibliography files #94

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

lorrden
Copy link

@lorrden lorrden commented Nov 25, 2023

Adds support for multiple bibliography files.

Introduces support for multiple bibliography files by treating bibtex-file as a comma separated list.

The search order for entries is in the file order.

This PR resolves #87

@lorrden lorrden marked this pull request as ready for review November 25, 2023 13:16
@lorrden
Copy link
Author

lorrden commented Nov 25, 2023

Just verified the changes by running this manually.

What I am uncertain of is what CiteProc::Processor is doing when it imports files with duplicated keys. Does it override the old items, or does it keep the first imported item?

@mojavelinux
Copy link
Member

I'm wondering whether this feature could be added to the existing bibtex-file attribute if there is a comma present (very unlikely in a filename). That way, you don't end up with mutually exclusive attributes. Just something to think about.

bibtex-file attribute can now be used for multiple files instead.
@lorrden
Copy link
Author

lorrden commented Nov 26, 2023

I'm wondering whether this feature could be added to the existing bibtex-file attribute if there is a comma present (very unlikely in a filename). That way, you don't end up with mutually exclusive attributes. Just something to think about.

Yes, probably a better idea. Fixed in latest commit.

Comment on lines 57 to 61
@biblio = []
bibfiles.each do |bibfile|
bibtex = BibTeX.open bibfile, filter: [LatexFilter]
@biblio += [bibtex]
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something more compact like:

@biblio = bibfiles.map { |bibfile| BibTeX.open bibfile, filter: [LatexFilter] }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up in latest patches

@@ -48,13 +48,17 @@ def apply(value)
# current document, and run the different steps to add the citations
# and bibliography
class Processor
def initialize(bibfile, links = false, style = 'ieee', locale = 'en-US',
def initialize(bibfiles, links = false, style = 'ieee', locale = 'en-US',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility it would be better to accept both a single string and an array of strings here. This would also simplify the patch in the tests since single-bib could still be handled with the old syntax, and only the new test using an array would have to be introduced.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String arguments restored in latest patch series

Also restored the old tests to pass strings instead.

@lorrden
Copy link
Author

lorrden commented Dec 13, 2023

I think this is ready for re-review now. Let me know if there is something else that need to be addressed.

@ciderhan
Copy link

Hello, thank you for the improvement. any progress on this capability? I am reusing asciidoc files maintained in another repository and adding them to the main repository as a submodule in Git. That's why I need to use two bibtex files; one from the injected repository and the other is maintained by me in the main repository.

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

Successfully merging this pull request may close these issues.

Allow multiple .bib files
4 participants