Skip to content

Can knitr::opts_knit$get("quarto.version") return the specific Quarto version? #13420

@gadenbuie

Description

@gadenbuie

Quarto sets the knitr option quarto.version = 1

quarto.version = 1,

This is then generally used as a signal that knitr is executing in a Quarto context with a check like

!is.null(knitr::opts_knit$get("quarto.version"))

or in some packages, like flextable there are more complicated checks that insinuate that quarto.version might change over time

is_in_quarto <- function() {
  if (getRversion() >= numeric_version("4.4.0")) {
    isTRUE(knitr::opts_knit$get("quarto.version") > 0)
  } else {
    isTRUE(knitr::opts_knit$get("quarto.version") > numeric_version("0"))
  }
}

I think it'd be helpful to have this version match the Quarto binary version. I can't find another way to find out, from R, what exact version of quarto is in use.

In v1.9 I think the following will be possible, but the quarto.version knitr option is definitely easier to access.

jsonlite::read_json(Sys.getenv("QUARTO_EXECUTE_INFO"))[["format"]][["metadata"]][["quarto-version"]]

Metadata

Metadata

Assignees

Labels

engines-knitrAnything regarding knitr enginesenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions