citeproc-java icon indicating copy to clipboard operation
citeproc-java copied to clipboard

citekey field in bibtex format should not contain blank spaces or commas

Open ebergasa opened this issue 2 years ago • 2 comments

Describe the bug While exporting to 'bibtex' format, citekey field is built by concatenating author names with underscores.

The problem occurs when there are blanks in family names. Blank spaces should be replaced by underscores as well.

Which version of citeproc-java are you using? 3.0.0-beta.2

Expected behavior bibtex citekey field should not contain blanks or commas.

As of BibTex format standard: The citekey can be any combination of alphanumeric characters including the characters "-", "_", and ":"

Used style and locale bibtex es-ES

Example code/unit test

    public static void main(String[] args) throws IOException {
        var item = new CSLItemDataBuilder().id("6501a713df0d06753d5bf43f")
                .type(CSLType.BOOK)
                .language("es")
                .author(    new CSLNameBuilder()
                            .family("Raya Díez")
                                .given("Esther")
                            .build(),
                        new CSLNameBuilder()
                                .literal("Arruga Serrano, Concepción")
                                .build()
                        )
                .issued(2021)
                .title("Brecha digital y competencias digitales: estudio de la situación en La Rioja")
                .build();
        
        var itemDataProvider = new ListItemDataProvider(List.of(item));
        
        var csl = new CSL(itemDataProvider, "bibtex", "es-ES");
        
        csl.registerCitationItems(itemDataProvider.getIds());
        csl.setOutputFormat("text");
        

Results in:

@book{raya díez_arruga serrano, concepción_2021, title={Brecha digital y competencias digitales: estudio de la situación en La Rioja}, author={Raya Díez, Esther and Arruga Serrano, Concepción}, year={2021} }

ebergasa avatar Oct 10 '23 08:10 ebergasa