Skip to content

Commit

Permalink
add doi2md function
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakillo committed Oct 21, 2024
1 parent 7137d9d commit 59a12bf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions R/doi2md.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
doi2md <- function(doi = NULL, style = NULL) {

doi <- gsub("https://doi.org/", "", doi)

dt <- rcrossref::cr_works(doi)$data

if (!is.null(style)) {
out <- rcrossref::cr_cn(doi, format = "text", style = "ecology-letters")
} else {

out <- paste(
paste(dt$author[[1]]$family, collapse = ", "),
paste0("(", substr(dt$created, start = 1, stop = 4), ")"),
paste0("[", dt$title, "](", "https://doi.org/", doi, ")."),
paste0("*", dt$container.title, "*"),
dt$volume,
paste0("(", dt$issue, "):"),
dt$page,
collapse = " "
)

}

cat(out)

}




0 comments on commit 59a12bf

Please sign in to comment.