R/which.R

Defines functions typr_which_typst

Documented in typr_which_typst

#' Identify Install Typst to Use
#'
#' @returns a character vector or `NULL` if no Typst is found
#' @export
#'
#' @examples
#' typr_which_typst()
typr_which_typst <- function() {
  opt <- getOption('typr.typst')

  if (!is.null(opt)) {
    if (length(opt) == 1 && opt == 'quarto') {
      opt <- c('quarto', 'typst')
    }
    return(opt)
  }

  if (has_typst_cli()) {
    'typst'
  } else if (has_quarto_typst()) {
    c('quarto', 'typst')
  } else {
    NULL
  }
}

Try the typr package in your browser

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

typr documentation built on June 8, 2025, 10:36 a.m.