Skip to content

Commit

Permalink
fix(packages): Parse and split all name fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Jun 15, 2024
1 parent 9d00c49 commit badb103
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 19 additions & 2 deletions packages/bibtex/bibliography.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ Bibliography = {
transEditor = function (item)
local r = {}
if item.editor then
r[#r + 1] = fluent:get_message("bibliography-edited-by")({ name = item.editor })
r[#r + 1] = fluent:get_message("bibliography-edited-by")({
name = Bibliography.Style.firstLastNames(item.editor),
})
end
if item.translator then
r[#r + 1] = fluent:get_message("bibliography-translated-by")({ name = item.translator })
r[#r + 1] = fluent:get_message("bibliography-translated-by")({
name = Bibliography.Style.firstLastNames(item.translator),
})
end
if #r then
return table.concat(r, ", ")
Expand Down Expand Up @@ -162,6 +166,19 @@ Bibliography = {
end
end,

firstLastNames = function (field)
local namelist = field or {}
if #namelist == 0 then
return ""
end
local names = {}
for i = 1, #namelist do
local author = namelist[i]
names[i] = author.ff .. " " .. author.ll
end
return Bibliography.Style.commafy(names)
end,

commafy = function (t, andword) -- also stolen from nbibtex
andword = andword or fluent:get_message("bibliography-and")
if #t == 1 then
Expand Down
6 changes: 5 additions & 1 deletion packages/bibtex/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ local function consolidateEntry (entry, label)
end
end
-- Names field split and parsed
for _, field in ipairs({"author", }) do
for _, field in ipairs({ "author", "editor", "translator", "shortauthor", "shorteditor", "holder" }) do
if consolidated[field] then
-- FIXME Check our corporate names behave, we are probably bad currently
-- with nested braces !!!
-- See biblatex manual v3.20 §2.3.3 Name Lists
-- e.g. editor = {{National Aeronautics and Space Administration} and Doe, John}
local names = namesplit(consolidated[field])
for i = 1, #names do
names[i] = parse_name(names[i])
Expand Down

0 comments on commit badb103

Please sign in to comment.