R/chunks-helpers.R

Defines functions get_what

get_what <- function(data, what, from){
  if ( any(what == "all") ) what <- pub_sections()
  res <- stats::setNames(lapply(what, function(z) {
    vv <- tryCatch(switch(z,
           front = front(data, from),
           body = body(data, from),
           back = back(data, from),
           title = title(data, from),
           abstract = abstract(data, from),
           executive_summary = exec_summary(data, from),
           doi = doi(data, from),
           categories = categories(data, from),
           authors = authors(data, from),
           aff = aff(data, from),
           keywords = keywords(data, from),
           refs_dois = refs_dois(data, from),
           refs = refs(data, from),
           publisher = publisher(data, from),
           journal_meta = journal_meta(data, from),
           article_meta = article_meta(data, from),
           acknowledgments = acknowledgments(data, from),
           permissions = permissions(data, from),
           history = history(data, from)
    ), error = function(e) e, warning = function(w) w)
    if (inherits(vv, c("error", "warning"))) NULL else vv
  }), what)
  res$.publisher <- from
  return(res)
}

Try the pubchunks package in your browser

Any scripts or data that you put into this service are public.

pubchunks documentation built on Sept. 4, 2020, 5:06 p.m.