Generate citations and bibliographies faster with citeproc-java 3.0.0

I’m very happy to announce the next iteration of citeproc-java, the CSL processor for Java. 🎉🎉

You can find the library and the full documentation here:
https://github.com/michel-kraemer/citeproc-java

Version 3.0.0 is a major rewrite that I’ve been working on for quite some time. The most notable change is that the library is now a pure Java implementation. It does not rely on citeproc-js any longer and, therefore, does not need a JavaScript interpreter like the previous versions did. This also means there will be fewer compatibility issues with other libraries or with different Java versions.

The performance you’ll get with the new version has improved a lot: citations and bibliographies for complex styles can now be generated within a few milliseconds, which is more than a hundred times faster than before.

citeproc-java 3.0.0 does not implement the full CSL specification yet. You might experience some inconsistencies or miss features. If this is the case, please file an issue. The majority of the specification has, however, been implemented and the library is stable and works very reliably. I’m testing it against the CSL Test Suite and at least 422 tests run successfully already (I haven’t included some of them yet, so the actual number might be higher). In fact, there are even more unit tests (in addition to the test suite) and the whole set includes more than 740 tests.

The API has slightly changed, so some migration steps might be necessary, depending on how you use citeproc-java. Please refer to the updated documentation.

Quick start

If you haven’t used citeproc-java before, here’s a quick example showing what the library can do. It generates an HTML bibliography in the APA style containing one journal paper:

CSLItemData item = new CSLItemDataBuilder()
    .type(CSLType.ARTICLE_JOURNAL)
    .title("Protein measurement with the Folin phenol reagent")
    .author(
        new CSLNameBuilder().given("Oliver H.").family("Lowry").build(),
        new CSLNameBuilder().given("Nira J.").family("Rosebrough").build(),
        new CSLNameBuilder().given("A. Lewis").family("Farr").build(),
        new CSLNameBuilder().given("Rose J.").family("Randall").build()
    )
    .issued(1951)
    .containerTitle("The Journal of biological chemistry")
    .volume(193)
    .issue(1)
    .page(265, 275)
    .build();
 
String bibl = CSL.makeAdhocBibliography("apa", item).makeString();

The output will be:

<div class="csl-bib-body">
  <div class="csl-entry">Lowry, O. H., Rosebrough, N. J., Farr, A. L., &amp; Randall, R. J. (1951). Protein measurement with the Folin phenol reagent. <span style="font-style: italic">The Journal of Biological Chemistry</span>, <span style="font-style: italic">193</span>(1), 265&ndash;275.</div>
</div>

Rendered, the output looks like this:

Lowry, O. H., Rosebrough, N. J., Farr, A. L., & Randall, R. J. (1951). Protein measurement with the Folin phenol reagent. The Journal of Biological Chemistry, 193(1), 265–275.

Find more examples and the full documentation in the citeproc-java GitHub repository.


Profile image of Michel Krämer

Posted by Michel Krämer
on 24 March 2024


Previous post

A cloud-based data processing and visualization pipeline for the fibre roll-out in Germany

Our new paper summarizes the work we’ve done together with Deutsche Telekom during the last six and a half years. We’ve built a cloud-based platform that speeds up the roll-out of fibre broadband Internet.

Related posts

Generating citations and bibliographies with CSL and citeproc-java

I’m thrilled to announce the first release of citeproc-java, a library to generate citations and bibliographies. It is similar to BibTeX but uses CSL under the hood and is therefore much more flexible.

citeproc-java 2.0.0 has just been released

The new major version offers support for Java 11 and is able to import YAML files. To improve performance, a GraalVM-based JavaScript runner has been added. The update also fixes a few minor bugs.

Command line tool for citations and bibliographies

Version 0.6 of citeproc-java introduces a command line tool that can be used to generate citations and bibliographies without setting up a complete development environment.