build_episode_html: Build a single episode html file

Description Usage Arguments Value Note See Also Examples

View source: R/build_episode.R

Description

This is a Carpentries-specific wrapper around pkgdown::render_page() with templates from varnish. This function is largely for internal use and will likely change.

Usage

1
2
3
4
5
6
7
8
build_episode_html(
  path_md,
  path_src = NULL,
  page_back = "index.md",
  page_forward = "index.md",
  pkg,
  quiet = FALSE
)

Arguments

path_md

the path to the episode markdown (not RMarkdown) file (usually via build_episode_md()).

path_src

the default is NULL indicating that the source file should be determined from the sandpaper-source entry in the yaml header. If this is not present, then this option allows you to specify that file.

page_back

the URL for the previous page

page_forward

the URL for the next page

pkg

a pkgdown object containing metadata for the site

quiet

if TRUE, messages are not produced. Defaults to TRUE.

Value

TRUE if the page was successful, FALSE otherwise.

Note

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

See Also

build_episode_md(), build_lesson(), build_markdown(), render_html()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
}
tmp <- tempfile()
create_lesson(tmp, open = FALSE)
suppressMessages(set_episodes(tmp, get_episodes(tmp), write = TRUE))
if (rmarkdown::pandoc_available("2.11")) {
  # we can only build this if we have pandoc
  build_lesson(tmp)
}

# create a new file in files
fun_file <- file.path(tmp, "episodes", "files", "fun.Rmd")
txt <- c(
 "---\ntitle: Fun times\n---\n\n",
 "# new page\n", 
 "This is coming from `r R.version.string`\n",
 "::: testimonial\n\n#### testimony!\n\nwhat\n:::\n"
)
file.create(fun_file)
writeLines(txt, fun_file)
hash <- tools::md5sum(fun_file)
res <- build_episode_md(fun_file, hash)
if (rmarkdown::pandoc_available("2.11")) {
  # we can only build this if we have pandoc
  build_episode_html(res, path_src = fun_file, 
    pkg = pkgdown::as_pkgdown(file.path(tmp, "site"))
  )
}

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