quarto-dev / quarto-dev/quarto

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

Open
#490 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

vscode
Dominant language
TypeScript
Stars
645
Forks
62
Avg merge
17h 42m
Merged PRs (30d)
13

Description

This was reported against the RStudio IDE, see https://github.com/rstudio/rstudio/issues/12768 for full details.

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

https://github.com/quarto-dev/quarto/blob/06678d55143a7d6de6c7f0232db0c5dcf8392ca6/packages/editor/src/behaviors/insert_citation/source_panels/insert_citation-source-panel-packages.tsx#L163

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": "jenny@rstudio.com",
            "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
            ]
        ]
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/editor/src/behaviors/insert_citation/source_panels/insert_citation-source-panel-packages.tsx at the cited conversion and inspect bibtextTypeToCSLType() in types.ts. Reproduce the devtools citation using the shown citeInfo and compare the generated CSL/BibTeX data. Done means the citation retains the appropriate type and note instead of producing the incorrect output described here.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, typescript
Domain
content, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.