R/pandoc_read.R

Defines functions pandoc_read

Documented in pandoc_read

#' Read a `Pandoc` File from some Supported Format
#'
#' @param file file to read
#' @param text string to use instead of file if set
#' @param from format of the file
#'
#' @return the `Pandoc` object
#' @export
pandoc_read <- function(file, text = NULL, from = pandoc_input_formats()) {
  from <- match.arg(from)
  if (is.null(text)) {
    args <- sprintf("-f %s -t json %s", shQuote(from), shQuote(normalizePath(file)))
  } else {
    args <- sprintf("-f %s -t json", shQuote(from))
  }
  pandoc <- system2(pandoc(), args, input = text, stdout=TRUE, stderr=TRUE)
  paste0(pandoc, collapse = "")
}

Try the flexsiteboard package in your browser

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

flexsiteboard documentation built on Nov. 16, 2022, 1:11 a.m.