tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.
https://reprex.tidyverse.org
Other
741 stars 80 forks source link

Could reprex set an environment variable while it is rendering #466

Closed olivroy closed 4 months ago

olivroy commented 4 months ago

Like pkgdown does

Sys.getenv("IN_PKGDOWN")

Something like

"IN_REPREX"

So it is easy to know you are in reprex.

I am trying to see how I could tackle #419 inside gt, but I am having a hard time finding out if we are in reprex or not.

The following function doesn't seem to be reliable?

in_reprex <- function() "gfm-yaml_metadata_block" %in% knitr::opts_knit$get("rmarkdown.pandoc.to")
olivroy commented 4 months ago

No need, reprex sets an option https://github.com/dmurdoch/rgl/pull/186

in_reprex <- function() 
  !is.null(getOption("reprex.current_venue"))