Skip to content

Commit e3a7dc1

Browse files
Omikhleiaalerque
authored andcommitted
fix(packages): Parse and split all bibtex name fields
Closes #2052
1 parent ee30165 commit e3a7dc1

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

packages/bibtex/bibliography.lua

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ Bibliography = {
119119
transEditor = function (item)
120120
local r = {}
121121
if item.editor then
122-
r[#r + 1] = fluent:get_message("bibliography-edited-by")({ name = item.editor })
122+
r[#r + 1] = fluent:get_message("bibliography-edited-by")({
123+
name = Bibliography.Style.firstLastNames(item.editor),
124+
})
123125
end
124126
if item.translator then
125-
r[#r + 1] = fluent:get_message("bibliography-translated-by")({ name = item.translator })
127+
r[#r + 1] = fluent:get_message("bibliography-translated-by")({
128+
name = Bibliography.Style.firstLastNames(item.translator),
129+
})
126130
end
127131
if #r then
128132
return table.concat(r, ", ")
@@ -162,6 +166,19 @@ Bibliography = {
162166
end
163167
end,
164168

169+
firstLastNames = function (field)
170+
local namelist = field or {}
171+
if #namelist == 0 then
172+
return ""
173+
end
174+
local names = {}
175+
for i = 1, #namelist do
176+
local author = namelist[i]
177+
names[i] = author.ff .. " " .. author.ll
178+
end
179+
return Bibliography.Style.commafy(names)
180+
end,
181+
165182
commafy = function (t, andword) -- also stolen from nbibtex
166183
andword = andword or fluent:get_message("bibliography-and")
167184
if #t == 1 then

packages/bibtex/init.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ local function consolidateEntry (entry, label)
101101
end
102102
end
103103
-- Names field split and parsed
104-
for _, field in ipairs({ "author" }) do
104+
for _, field in ipairs({ "author", "editor", "translator", "shortauthor", "shorteditor", "holder" }) do
105105
if consolidated[field] then
106+
-- FIXME Check our corporate names behave, we are probably bad currently
107+
-- with nested braces !!!
108+
-- See biblatex manual v3.20 §2.3.3 Name Lists
109+
-- e.g. editor = {{National Aeronautics and Space Administration} and Doe, John}
106110
local names = namesplit(consolidated[field])
107111
for i = 1, #names do
108112
names[i] = parse_name(names[i])

0 commit comments

Comments
 (0)