Skip to content

Commit d4aac39

Browse files
authored
Fix authors written with only a given name (#15372)
parseAuthor recognized a flat author object only when it had a family name. An object with only `given` was flagged unrecognized, and the strict call made while normalizing metadata then dropped the whole author list, so a recognized author next to it vanished too. A given name is now enough to recognize a flat author. The name is kept as written: a lone given stays a given name. * Don't parse a name literal that Quarto built itself normalizeName builds a literal from the written name parts, then BibTeX-parsed that literal to fill in the missing family or given name. A lone word parses as a family name, so `name: {given: Socrates}` gained the family name Socrates, and `name: {family: Smith Jones}` was split into the given name Smith and the family name Jones. Parse the literal only when the author wrote it. Written parts are kept as written, and a written literal is still parsed.
1 parent 2e25318 commit d4aac39

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

‎news/changelog-1.12.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ All changes included in 1.12:
3131

3232
- ([#12649](https://github.com/quarto-dev/quarto-cli/issues/12649)): Fix name particles such as `de` or `van` missing from author names in title blocks and JATS output.
3333
- ([#15344](https://github.com/quarto-dev/quarto-cli/pull/15344)): A Div with an id that starts with a heading now renders as that heading's section, which takes the Div's classes, so CSS such as `div.myclass > section` no longer matches. Quarto keeps the heading id on the section, so crossrefs and table of contents links still target the heading; in beamer, DocBook, ConTeXt, AsciiDoc and revealjs the Div's id is no longer written.
34+
- ([#15371](https://github.com/quarto-dev/quarto-cli/issues/15371)): Fix authors written with only a given name being dropped from the title block and JATS output, or getting the given name repeated as the family name in JATS.
3435

3536
### `html`
3637

‎src/core/author.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function parseAuthor(authorRaw: unknown, strict?: boolean) {
9191
}
9292

9393
parsed.push(auth);
94-
} else if (author[kFamily]) {
94+
} else if (author[kFamily] || author[kGiven]) {
9595
const given = author[kGiven];
9696
const family = author[kFamily];
9797
const dropping = author[kDropping];

‎src/resources/filters/modules/authors.lua‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,15 @@ end
438438
-- family and given names
439439
local function normalizeName(name)
440440
-- no literal name, create one
441-
if name[kLiteralName] == nil then
441+
local literalWritten = name[kLiteralName] ~= nil
442+
if not literalWritten then
442443
name[kLiteralName] = createNameLiteral(name)
443444
end
444445

445-
-- no family or given name, parse the literal and create one
446+
-- no family or given name, parse the written literal and create one.
447+
-- A literal built from the parts carries nothing new to parse.
446448
if name[kFamilyName] == nil or name[kGivenName] == nil then
447-
if name[kLiteralName] then
449+
if literalWritten and name[kLiteralName] then
448450
local parsedName = bibtexParseName(name[kLiteralName])
449451
if type(parsedName) == 'table' then
450452
-- fields the author wrote win over what the parse infers
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Given-only author names
3+
author:
4+
- given: Plato
5+
- name: Ada Lovelace
6+
- name:
7+
given: Socrates
8+
- name:
9+
literal: Aristotle
10+
- name:
11+
family: Smith Jones
12+
format:
13+
html: default
14+
jats: default
15+
_quarto:
16+
tests:
17+
html:
18+
ensureFileRegexMatches:
19+
- ['<p>Plato\s*</p>', '<p>Ada Lovelace\s*</p>', '<p>Socrates\s*</p>', '<p>Aristotle\s*</p>', '<p>Smith Jones\s*</p>']
20+
- []
21+
jats:
22+
ensureFileRegexMatches:
23+
- ['<given-names>Plato</given-names>', '<surname>Lovelace</surname>', '<given-names>Socrates</given-names>', '<surname>Aristotle</surname>', '<surname>Smith Jones</surname>']
24+
- ['<surname>Plato</surname>', '<surname>Socrates</surname>', '<surname>SocratesSocrates</surname>', '<given-names>Smith</given-names>']
25+
---
26+
27+
An author written with only a given name must be kept, and must not take the given name as a family name.
28+
29+
- `Plato` is a flat object with only `given`: it is a recognized author, not an unknown shape.
30+
- `Ada Lovelace` is a plain string next to it: a recognized author must not be dropped because of its neighbour.
31+
- `Socrates` is a `name:` table with only `given`: the literal built from it must not be parsed to invent a family name.
32+
- `Aristotle` is a written `literal` alone: the literal was written, so it is still parsed into a family name.
33+
- `Smith Jones` is a written `family` alone: it keeps the full surname and gets no inferred given name.

0 commit comments

Comments
 (0)