build_episode_md: Build an episode to markdown

Description Usage Arguments Value Note See Also Examples

View source: R/build_episode.R

Description

This uses knitr::knit() with custom options set for the Carpentries template. It runs in a separate process to avoid issues with user-specific options bleeding in.

Usage

1
2
3
4
5
6
7
8
9
build_episode_md(
  path,
  hash = NULL,
  outdir = path_built(path),
  workdir = path_built(path),
  workenv = new.env(),
  profile = "lesson-requirements",
  quiet = FALSE
)

Arguments

path

path to the RMarkdown file

hash

hash to prepend to the output. This parameter is deprecated and is effectively useless.

outdir

the directory to write to

workdir

the directory where the episode should be rendered

quiet

if TRUE, output is suppressed, default is FALSE to show knitr output.

env

a blank environment

Value

the path to the output, invisibly

Note

this function is for internal use, but exported for those who know what they are doing.

See Also

render_html(), build_episode_html()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if (.Platform$OS.type == "windows") {
  options("sandpaper.use_renv" = FALSE)
}
if (!interactive() && getOption("sandpaper.use_renv")) {
  old <- renv::config$cache.symlinks()
  options(renv.config.cache.symlinks = FALSE)
  on.exit(options(renv.config.cache.symlinks = old), add = TRUE)
}
fun_dir <- tempfile()
dir.create(fs::path(fun_dir, "episodes"), recursive = TRUE)
fun_file <- file.path(fun_dir, "episodes", "fun.Rmd")
file.create(fun_file)
txt <- c(
 "---\ntitle: Fun times\n---\n\n",
 "# new page\n", 
 "This is coming from `r R.version.string`"
)
writeLines(txt, fun_file)
res <- build_episode_md(fun_file, outdir = fun_dir, workdir = fun_dir)

zkamvar/sandpaper documentation built on Nov. 25, 2021, 1:16 p.m.