Skip to content
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

Inserting R Package citations in the Quarto visual editor generates incorrect BibTex #490

Open
gtritchie opened this issue Jul 23, 2024 · 1 comment
Labels

Comments

@gtritchie
Copy link
Collaborator

gtritchie commented Jul 23, 2024

This was reported against the RStudio IDE, see rstudio/rstudio#12768 for full details.

The problems start when the citation returned from R is converted to CSL (Citation Style Language) here:

The citeInfo for the "devtools" example is:

{
    "type": "Manual",
    "title": "devtools: Tools to Make Developing R Packages Easier",
    "url": "https://CRAN.R-project.org/package=devtools",
    "note": "R package version 2.4.5",
    "doi": null,
    "publisher": null,
    "institution": null,
    "address": null,
    "journal": null,
    "year": "2022",
    "booktitle": null,
    "chapter": null,
    "number": null,
    "volume": null,
    "pages": null,
    "series": null,
    "school": null,
    "author": [
        {
            "given": [
                "Hadley"
            ],
            "family": "Wickham",
            "email": null,
            "role": "aut"
        },
        {
            "given": [
                "Jim"
            ],
            "family": "Hester",
            "email": null,
            "role": "aut"
        },
        {
            "given": [
                "Winston"
            ],
            "family": "Chang",
            "email": null,
            "role": "aut"
        },
        {
            "given": [
                "Jennifer"
            ],
            "family": "Bryan",
            "email": "[email protected]",
            "role": "aut"
        }
    ],
    "editor": []
}

It is transformed to the following, changing the type and losing the note as described in the issue. The type mapping happens in types.ts: bibtextTypeToCSLType().

{
    "type": "article",
    "title": "devtools: Tools to Make Developing R Packages Easier",
    "URL": "https://CRAN.R-project.org/package=devtools",
    "author": [
        {
            "family": "Wickham",
            "given": "Hadley"
        },
        {
            "family": "Hester",
            "given": "Jim"
        },
        {
            "family": "Chang",
            "given": "Winston"
        },
        {
            "family": "Bryan",
            "given": "Jennifer"
        }
    ],
    "issued": {
        "date-parts": [
            [
                2022
            ]
        ]
    }
}
@gtritchie
Copy link
Collaborator Author

gtritchie commented Jul 23, 2024

CSL doesn't have a "Manual" type, but perhaps "report" would be a better substitute than "article"?

report
A technical report, government report, white paper, brief, or similar work distributed by an institution;
Also used for manuals and similar technical documentation (e.g. a software, instrument, or test manual);

from https://docs.citationstyles.org/en/stable/specification.html#appendix-iii-types

UPDATE: The code, as currently written, intended to map BibTeX "manual" to CSL "book", but it is case-sensitive and is messed up by "Manual", falling back to the default of "article". So that part, at least, should be a simple fix.

case BibTextTypes.proceedings.type:
case BibTextTypes.manual.type:
case BibTextTypes.book.type:
return cslTypes.book;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants