Skip to content

Cite multiple entries as a single citation for CSL in-text#15706

Merged
Siedlerchr merged 3 commits into
JabRef:mainfrom
pluto-han:fix-for-15703
May 11, 2026
Merged

Cite multiple entries as a single citation for CSL in-text#15706
Siedlerchr merged 3 commits into
JabRef:mainfrom
pluto-han:fix-for-15703

Conversation

@pluto-han

@pluto-han pluto-han commented May 8, 2026

Copy link
Copy Markdown
Collaborator

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 createInTextCitationGroupText method to create a single in-text citation.

Steps to test

  1. Open JabRef and a LibreOffice Writer document
  2. Open Chocolate.bib in JabRef
  3. Connect to the running LO instance
  4. Select any CSL style
  5. Select multiple entries and press in-text cite

Observe they are cited as a single reference mark.
image

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Consolidate multiple CSL in-text citations into single mark

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• 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
Diagram
flowchart LR
  A["Multiple BibEntries"] -->|"createInTextCitationGroupText"| B["Single Citation String"]
  B -->|"insertReferences"| C["Single Reference Mark"]
  D["Update Style"] -->|"createInTextCitationGroupText"| B
Loading

Grey Divider

File Changes

1. jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java 🐞 Bug fix +16/-33

Implement grouped in-text citation generation

• Replaced loop-based citation insertion with new createInTextCitationGroupText helper method
• Simplified insertInTextCitation to create single grouped citation instead of multiple separate
 ones
• Refactored updateAllCitationsWithNewStyle to use the new helper method for consistent grouping
• Added StringJoiner import for cleaner citation concatenation

jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java


2. CHANGELOG.md 📝 Documentation +1/-0

Document CSL in-text citation grouping fix

• Added entry documenting the fix for issue #15703 regarding multiple CSL in-text citations

CHANGELOG.md


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1)

Grey Divider


Remediation recommended

1. No tests for citation grouping 📘 Rule violation ☼ Reliability
Description
This PR changes in-text citation generation behavior by introducing grouped citation text, but no
corresponding tests were added/updated to cover the new behavior. This increases regression risk for
CSL in-text citation formatting and mark insertion/update flows.
Code

jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java[R139-141]

+        String citation = createInTextCitationGroupText(selectedStyle, isAlphanumericStyle, isNumericStyle, entries, bibDatabaseContext);
+        OOText ooText = OOFormat.setLocaleNone(OOText.fromString(citation));
+        insertReferences(cursor, entries, ooText, isNumericStyle, CSLCitationType.IN_TEXT);
Evidence
PR Compliance ID 16 requires tests to be added/updated for behavior changes in logic code. The diff
shows a behavioral change to generate a single grouped in-text citation string via
createInTextCitationGroupText(...) and insert/update references using the grouped text, but the PR
diff contains no test changes covering this new grouping behavior.

AGENTS.md
jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java[139-141]
jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java[323-331]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR changes CSL in-text citation behavior to emit a single grouped citation string, but no tests were added/updated to verify the new behavior.

## Issue Context
`insertInTextCitation(...)` and the IN_TEXT update flow now depend on `createInTextCitationGroupText(...)` to join multiple entry citations into one mark/text.

## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java[139-141]
- jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java[323-331]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@Siedlerchr

Copy link
Copy Markdown
Member

Definitely an improvement!

@Siedlerchr Siedlerchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That should already generate a combined citaiton

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels May 8, 2026
@subhramit subhramit requested a review from koppor May 8, 2026 22:07
String prefix = CSLFormatUtils.generateAuthorPrefix(currentEntry, bibDatabaseContext);
citation = prefix + citation;
} else if (!isAlphaNumericStyle) {
citation = CSLFormatUtils.changeToInText(citation);

@subhramit subhramit May 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

See if that can be replaced by using citeproc's native authorOnly and suppressAuthor. See examples here.

Yep good idea. Should i implement it in this PR or in a seperate one?

@subhramit subhramit May 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@Siedlerchr Siedlerchr added this pull request to the merge queue May 11, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label May 11, 2026
Merged via the queue into JabRef:main with commit ca0f6b4 May 11, 2026
121 of 130 checks passed

/// 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(", ");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Follow-up: aptly named constant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: libre-office project: gsoc status: changes-required Pull requests that are not yet complete status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple entries are not cited as a single reference mark for CSL in-text

3 participants