Skip to content

Commit 7b8c15e

Browse files
committed
tests: check a duplicate key in a YAML bibliography fails the render
The delimited fixture used to carry a duplicate title to show that Quarto's own read of the file (json: true in bibliography.ts) keeps the last value, as Pandoc did. Pandoc 3.13 rejects duplicate keys when the render reads the bibliography, so that path is unreachable and the fixture dropped the duplicate. This document keeps the case covered from the user's side: the render fails with an error naming the file, line and column. With Pandoc 3.10 it renders and the test fails. The bibliography.ts comment claimed Pandoc also keeps the last value; it now says Pandoc rejects the duplicate.
1 parent 3bffdef commit 7b8c15e

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎src/core/bibliography.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export async function renderToCSLJSON(
111111
// Pandoc has no reader for a YAML bibliography: read as markdown, it
112112
// only works when wrapped in --- delimiters. Like --bibliography, use
113113
// the first YAML document, either a references: map or a bare array.
114-
// json: true lets a duplicate key win last, as pandoc does.
114+
// json: true lets a duplicate key win last instead of throwing here;
115+
// pandoc itself rejects duplicate keys when it reads the bibliography.
115116
const firstDoc = loadAll(Deno.readTextFileSync(absBiblioPath), null, {
116117
schema: kBibliographyYamlSchema,
117118
json: true,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Scholar metadata for a YAML bibliography with a duplicate key
3+
format: html
4+
google-scholar: true
5+
bibliography: references-duplicate.yaml
6+
_quarto:
7+
tests:
8+
html:
9+
shouldError: default
10+
printsMessage:
11+
level: ERROR
12+
regex: 'references-duplicate\.yaml:5:3: references\[0\]: duplicate key "title"'
13+
---
14+
15+
The bibliography repeats the `title` key in one reference. Pandoc rejects it, so the render fails with an error pointing at the duplicate.
16+
17+
This article cites one work [@cited].
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
references:
2+
- id: cited
3+
type: article-journal
4+
title: Superseded title
5+
title: Cited reference
6+
author:
7+
- family: Smith
8+
given: Alice
9+
issued:
10+
date-parts:
11+
- [2024]

0 commit comments

Comments
 (0)