Skip to content

Commit

Permalink
format.citation() doesn't have the bibtex argument in R 3.2.x; use st…
Browse files Browse the repository at this point in the history
…yle = 'text' instead
  • Loading branch information
yihui committed Oct 2, 2024
1 parent 4e2e5a9 commit 12eec2f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,15 @@ pkg_news = function(name = detect_pkg(), path = detect_news(name), recent = 1, .
pkg_citation = function(name = detect_pkg()) {
res = uapply(citation(name), function(x) {
x = tweak_citation(x)
unname(c(format(x, bibtex = FALSE), fenced_block(toBibtex(x), 'latex')))
unname(c(format(x, style = 'text'), fenced_block(toBibtex(x), 'latex')))
})
new_asis(res)
}

# dirty hack to add year if missing, and remove header
# dirty hack to add year if missing
tweak_citation = function(x) {
cls = class(x)
x = unclass(x)
attr(x[[1]], 'header') = attr(x, 'package') = NULL
if (is.null(x[[1]]$year)) x[[1]]$year = format(Sys.Date(), '%Y')
class(x) = cls
x
Expand Down

0 comments on commit 12eec2f

Please sign in to comment.