citHeader("To cite the 'rmarkdown' package in publications, please use:")

year = sub('.*(2[[:digit:]]{3})-.*', '\\1', meta$Date, perl = TRUE)
if (length(year) == 0) year = format(Sys.Date(), '%Y')
vers = paste('R package version', meta$Version)
auth = format(Filter(function(p) 'aut' %in% p$role, as.person(meta$Author)), c('given', 'family'))

citEntry(
  entry = 'manual',
  title = paste('rmarkdown:', meta$Title),
  author = auth,
  year = year,
  note = vers,
  url = strsplit(meta$URL, ',')[[1]][1],
  textVersion = paste0(
    paste(auth, collapse = ' and '), ' (', year, '). rmarkdown: ', meta$Title, '. ', vers, '.',
    ' URL https://rmarkdown.rstudio.com.'
  )
)

citEntry(
  entry = 'book',
  title = 'R Markdown: The Definitive Guide',
  author = c('Yihui Xie', 'J.J. Allaire', 'Garrett Grolemund'),
  publisher = 'Chapman and Hall/CRC',
  address = 'Boca Raton, Florida',
  year = '2018',
  note = 'ISBN 9781138359338',
  url = 'https://bookdown.org/yihui/rmarkdown',
  textVersion = paste(
    'Yihui Xie and J.J. Allaire and Garrett Grolemund (2018).',
    'R Markdown: The Definitive Guide.', 'Chapman and Hall/CRC. ISBN 9781138359338.',
    'URL https://bookdown.org/yihui/rmarkdown.'
  )
)

citEntry(
  entry = 'book',
  title = 'R Markdown Cookbook',
  author = c('Yihui Xie', 'Christophe Dervieux', 'Emily Riederer'),
  publisher = 'Chapman and Hall/CRC',
  address = 'Boca Raton, Florida',
  year = '2020',
  note = 'ISBN 9780367563837',
  url = 'https://bookdown.org/yihui/rmarkdown-cookbook',
  textVersion = paste(
    'Yihui Xie and Christophe Dervieux and Emily Riederer (2020).',
    'R Markdown Cookbook.', 'Chapman and Hall/CRC. ISBN 9780367563837.',
    'URL https://bookdown.org/yihui/rmarkdown-cookbook.'
  )
)
