Cite multiple entries as a single citation for CSL in-text#15706
Conversation
Review Summary by QodoConsolidate multiple CSL in-text citations into single mark
WalkthroughsDescription• Consolidate multiple CSL in-text citations into single reference mark • Extract citation grouping logic into reusable helper method • Apply grouping to both insertion and style update operations Diagramflowchart LR
A["Multiple BibEntries"] -->|"createInTextCitationGroupText"| B["Single Citation String"]
B -->|"insertReferences"| C["Single Reference Mark"]
D["Update Style"] -->|"createInTextCitationGroupText"| B
File Changes1. jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java
|
Code Review by Qodo
1. No tests for citation grouping
|
|
Definitely an improvement! |
Siedlerchr
left a comment
There was a problem hiding this comment.
That should already generate a combined citaiton
| String prefix = CSLFormatUtils.generateAuthorPrefix(currentEntry, bibDatabaseContext); | ||
| citation = prefix + citation; | ||
| } else if (!isAlphaNumericStyle) { | ||
| citation = CSLFormatUtils.changeToInText(citation); |
There was a problem hiding this comment.
Possible future exploration for @pluto-han following from @Siedlerchr's comment
I think downstream of this function we are using JabRef's style of extracting authors and joining with the numeric part to convert to in-text.
See if that can be replaced by using citeproc's native authorOnly and suppressAuthor. See examples here.
This can help us add more methods in CitationStyleGenerator. We may be able to make our own generateInTextCitation like generateCitation and generateBibliography there.
There was a problem hiding this comment.
See if that can be replaced by using citeproc's native
authorOnlyandsuppressAuthor. See examples here.
Yep good idea. Should i implement it in this PR or in a seperate one?
There was a problem hiding this comment.
Let that be separate. Let's solve one thing at a time, as incremental changes are easier to review and track. Feel free to open a tracking issue for this refactoring, though.
|
|
||
| /// Helper method for creating citation group for `insertInTextCitation` and `updateAllCitationsWithNewStyle` | ||
| private @NonNull String createInTextCitationGroupText(CitationStyle style, boolean isAlphaNumericStyle, boolean isNumericStyle, List<BibEntry> entries, BibDatabaseContext bibDatabaseContext) { | ||
| StringJoiner citations = new StringJoiner(", "); |
There was a problem hiding this comment.
Follow-up: aptly named constant
Related issues and pull requests
Closes #15703
PR Description
When insert multiple references at once using CSL in-text, entries are seperated into multiple reference marks instead of one single reference mark.
This PR adds a
createInTextCitationGroupTextmethod to create a single in-text citation.Steps to test
Observe they are cited as a single reference mark.

Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)