Skip to content

Commit

Permalink
Protect against author with no valid roles
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Sep 18, 2024
1 parent 1cc8a6f commit 445500c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions data/filters/prepare-credit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ local function prepare_credit (meta)
meta.hasRoles = false
for _, author in ipairs(meta.authors or {}) do
if author.roles then
meta.hasRoles = true
roleList = {}
for _, roleDict in ipairs(author.roles) do
roleDict = clean_role_dict(roleDict)
Expand All @@ -79,7 +78,10 @@ local function prepare_credit (meta)
table.insert(roleList, role)
end
end
author.rolesString = join_with_commas_and(roleList)
if #roleList > 0 then
meta.hasRoles = true
author.rolesString = join_with_commas_and(roleList)
end
end
end
return meta
Expand Down
2 changes: 2 additions & 0 deletions data/templates/default.latex
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ $if(hasRoles)$
\section{Author Contributions}\label{author-contributions}
\begin{enumerate}
$for(authors)$
$if(it.rolesString)$
\item $it.name$ - $it.rolesString$
$endif$
$endfor$
\end{enumerate}
$endif$
Expand Down
2 changes: 2 additions & 0 deletions data/templates/preprint.latex
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ $if(hasRoles)$
\section{Author Contributions}\label{author-contributions}
\begin{enumerate}
$for(authors)$
$if(it.rolesString)$
\item $it.name$ - $it.rolesString$
$endif$
$endfor$
\end{enumerate}
$endif$
Expand Down

0 comments on commit 445500c

Please sign in to comment.