Skip to content

Commit

Permalink
Remove extra comments in Authors@R
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Feb 3, 2025
1 parent cef1321 commit c3fd438
Show file tree
Hide file tree
Showing 2 changed files with 478 additions and 522 deletions.
24 changes: 24 additions & 0 deletions R/parse_authors_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ parse_authors_r <- function(authors_r_string) {
)

authors_persons <- lapply(str2expression(authors_r_string), eval)

# Drop extra comments
authors_persons[!is.na(authors_persons)] <- lapply(
authors_persons[!is.na(authors_persons)],
function(x) {
# We cannot use *apply() directly because it doesn't recreate a nice
# person object (as a list of person objects). Hence why we "manually"
# recreate it via c(person, person)
do.call(
c,
# person setter methods lose the comment field names so we unclass() and
# reclass instead
lapply(x, function(y) {
w <- unclass(y)
w[[1]]$comment <- y$comment[names(y$comment) %in% c("ORCID", "ROR")]
if (length(w[[1]]$comment) == 0) {
w[[1]]$comment <- NULL
}
class(w) <- class(y)
return(w)
})
)
}
)

if (length(authors_persons) == 1) {
authors_persons <- authors_persons[[1]]
Expand Down
Loading

0 comments on commit c3fd438

Please sign in to comment.