Skip to content

YAML bibliographies require an object with references and do not accept arrays #10452

@dhimmel

Description

@dhimmel

migrated from quarto-dev/quarto-cli#11656

Currently, the following bibliography.json file works as intended in a document that cites @osmnx and uses the citeproc filter:

[
    {
        "id": "osmnx",
        "type": "article-journal",
        "title": "OSMnx: New methods for acquiring, constructing, analyzing, and visualizing complex street networks"
    }
]

However, if we convert the JSON to YAML, no references will be loaded from bibliography.yaml:

- id: osmnx
  type: article-journal
  title: 'OSMnx: New methods for acquiring, constructing, analyzing, and visualizing complex street networks'

The workaround is easy, to use a dictionary/object as the top-level of the YAML with a key for references whose values are the array of CSL data references:

references:
- id: osmnx
  type: article-journal
  title: 'OSMnx: New methods for acquiring, constructing, analyzing, and visualizing complex street networks'

Accepting an array of references via YAML would make sense because

  • for parity with the JSON handling
  • since the official CSL Data spec specifies an array
  • it used to work in older versions of pandoc (if I'm not mistaken)

Noting extra context provided by @jgm at quarto-dev/quarto-cli#11656 (comment):

Not really intentional, nor unintentional. I reused a function yamlToRefs that is defined in the Markdown reader. This is what the Markdown reader uses to extract references from the metadata, and obviously it needs to look for a references key. This is turn is just a wrapper around yamlBsToRefs (which operates on a bytestring). It would probably be harmless to adjust yamlBsToRefs, which currently just returns an empty list of references if the YAML is not a dictionary/object, to also handle the case where we have an array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions