Skip to content

CSL4LibreOffice - H [Non-bibliographic styles] #12996

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

Merged
merged 30 commits into from
Apr 25, 2025

Conversation

subhramit
Copy link
Member

@subhramit subhramit commented Apr 24, 2025

Follow-up to #12951
Fixes #12990 (comment)

Support for non-bibliographic styles

Certain styles specified in our internal .csl files had a missing "bibliography" format specification section. Turns out there are styles that specify only citation formatting without bibliography.
[Fun fact: Some of these styles happen to be "note" citation styles (characterized by citation-format="note" in the source)].

This PR introduces support for such styles, thus enabling support for 82 new styles like "Oxford Art Journal", "Journal of Law, Medicine & Ethics", "Australian Historical Studies", "Business and Human Rights Journal", "Bluebook Law Review", "Journal of Applied Philosophy", "The Journal of Clinical Ethics", "South African Law Journal", "International Review of the Red Cross" and so on.

We now support a total of 2680 built-in styles.

The entire list of additions can be found below:

- Agora
- AIB Studi
- Ancilla Iuris
- Art History
- Australian Historical Studies
- Bluebook Inline
- Bluebook Law Review
- Brumaire Verlag
- Business and Human Rights Journal
- Byzantine and Modern Greek Studies
- Cambridge Quarterly of Healthcare Ethics
- Catholic Biblical Association
- Chaucer Review
- Common Market Law Review
- Comparativ
- Comparative Politics
- Developing World Bioethics
- Early Medieval Europe
- Early Music History
- Ephemerides Theologicae Lovanienses
- Ethics Book Reviews
- Geopolitics
- Geschichte und Gesellschaft
- Health and Human Rights Journal
- Henoch
- History and Theory
- Humanistica Lovaniensia Journal of Neo-Latin Studies
- Instrumenta Patristica et Mediaevalia
- International Affairs
- International Relations
- International Review of the Red Cross
- International Security
- ISO 690 (Note, Czech version)
- Journal for the History of Astronomy
- Journal of Applied Philosophy
- Journal of Early Christian Studies
- Journal of International Peacekeeping
- Journal of Law, Medicine & Ethics
- Journal of Political Ideologies
- Journal of Political Philosophy
- Journal of the History of Collections
- Journal of the Indian Law Institute
- Journal of the Warburg and Courtauld Institutes
- Journal of Value Inquiry
- Leonardo
- London Review of International Law
- Mediaeval Studies
- Medical History
- Mercatus Center
- Oxford Art Journal
- Past and Present
- Philosophy and Public Affairs
- Pisa University Press
- Politix
- Refugee Survey Quarterly
- Review of International Studies
- Schweizerische Zeitschrift für Geschichte (Swiss Journal of History)
- Social History of Medicine
- Société Française d'Égyptologie
- South African Law Journal
- Speculum
- Stellenbosch Law Review
- Studia Theologica
- Textual Practice
- The British Journal for the History of Science
- The Chinese Journal of International Politics
- The Historical Journal
- The Journal of Clinical Ethics
- The Journal of Comparative Law
- Thomson Reuters Legal Tax and Accounting Australia
- Transnational Environmental Law
- U Schyłku Starożytności (In the Late Antiquity)
- United Nations Development Programme ICCA Legal Review
- Zeitgeschichte
- Zeitschrift für Antikes Christentum (Journal of Ancient Christianity)
- Zeitschrift für die Geschichte des Oberrheins
- Zeitschrift für Geschichtsdidaktik
- Zeitschrift für Medien und Kulturforschung
- Zeitschrift für Medienwissenschaft
- Zeitschrift für Ostmitteleuropa-Forschung
- Zeitschrift für Parlamentsfragen
- Zeitschrift für Politik

Note:

  • The Make/Sync bibliography button will be disabled when such a style is selected.
  • The preview viewer will display the citation instead of the bibliography preview for these styles.
  • Tests added for these new variants.
  • The JSON entries in the generated CSL catalog now have an additional field:
{
  "path" : "academy-of-management-review.csl",
  "isNumeric" : false,
  "hasBibliography" : true,
  "title" : "Academy of Management Review"
}

Other improvements

  • Redundant variants of overloaded methods were collapsed in CitationStyleGenerator.
  • Refactored and restructured some existing tests into more appropriate places.
  • Added test for CitationStyleCatalogGenerator.
  • Fixed old JavaDoc to adapt to current context post the CSL project.
  • Simplified RegEx for updating bibliography citation numbers.
  • De-coupled certain classes that should not be inter-dependent.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • [/] Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

… new tests, collapse redundant methods.

Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
This reverts commit d8eff92.
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
@subhramit subhramit requested a review from Siedlerchr April 24, 2025 15:33
INTERNAL_STYLES.add(style);
}
} catch (IOException e) {
LOGGER.error("Error loading style file: {}", path, e);
styleCount--;
}
}
LOGGER.info("Loaded {} CSL styles", styleCount);
LOGGER.info("Loaded {} CSL styles", styleCount);
Copy link

Choose a reason for hiding this comment

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

The logging statement should not be reformatted unless new statements are added. The patch only changes indentation without adding new logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

It corrects the indent

*/
public record StyleInfo(String title, boolean isNumericStyle) {
public record StyleInfo(String title, boolean isNumericStyle, boolean hasBibliography) {
Copy link

Choose a reason for hiding this comment

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

The JavaDoc for the StyleInfo record was updated to include 'hasBibliography', but the JavaDoc for the createCitationStyleFromSource method was not updated to reflect the change in the CitationStyle constructor.

Copy link
Member Author

Choose a reason for hiding this comment

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

No need

@@ -18,6 +18,10 @@ public CitationStylePreviewLayout(CitationStyle citationStyle, BibEntryTypesMana

@Override
public String generatePreview(BibEntry entry, BibDatabaseContext databaseContext) {
if (!citationStyle.hasBibliography()) {
Copy link

Choose a reason for hiding this comment

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

The patch introduces a duplicate check for 'citationStyle.hasBibliography()' which is already present in the existing code. This results in code duplication and should be refactored to avoid redundancy.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just for conservative safety.

Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
koppor
koppor previously approved these changes Apr 24, 2025
@Test
void discoverInternalCitationStylesNotNull() {
List<CitationStyle> styleList = CSLStyleLoader.getInternalStyles();
assertNotNull(styleList);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe, assertNotEquals(List.of(), styleList to check that the list has some contents?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, done

Copy link
Member Author

Choose a reason for hiding this comment

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

I think assertFalse(styleList.isEmpty()) is equivalent for more brevity, changed to it

Comment on lines -58 to -68
public static String getBibliographyTitle() {
return bibliographyTitle;
}

public static String getBibliographyHeaderFormat() {
return bibliographyHeaderFormat;
}
private static final Pattern YEAR_IN_CITATION_PATTERN = Pattern.compile("(.)(.*), (\\d{4}.*)");

public static void setBibliographyProperties(OpenOfficePreferences openOfficePreferences) {
bibliographyTitle = openOfficePreferences.getCslBibliographyTitle();
bibliographyHeaderFormat = openOfficePreferences.getCslBibliographyHeaderFormat();
Copy link
Member Author

@subhramit subhramit Apr 24, 2025

Choose a reason for hiding this comment

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

Removal as an outcome of discussion at https://github.com/JabRef/jabref/pull/12784/files#r2058893104

Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
@subhramit subhramit added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers component: libre-office labels Apr 25, 2025
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Copy link

trag-bot bot commented Apr 25, 2025

@trag-bot didn't find any issues in the code! ✅✨

1 similar comment
Copy link

trag-bot bot commented Apr 25, 2025

@trag-bot didn't find any issues in the code! ✅✨

tsantalis added a commit to tsantalis/RefactoringMiner that referenced this pull request Apr 25, 2025
JabRef/jabref#12996
src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java
@subhramit subhramit added status: awaiting second review For non-trivial changes and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Apr 25, 2025
@Siedlerchr Siedlerchr added this pull request to the merge queue Apr 25, 2025
Merged via the queue into JabRef:main with commit 2616b5e Apr 25, 2025
1 check passed
@Siedlerchr Siedlerchr deleted the non-bibliographic-styles branch April 25, 2025 19:28
@subhramit subhramit removed the status: awaiting second review For non-trivial changes label Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants