render_html: Render html from a markdown file

Description Usage Arguments Value Examples

View source: R/render_html.R

Description

This uses rmarkdown::pandoc_convert() to render HTML from a markdown file. We've specified pandoc extensions that align with the features desired in the Carpentries such as markdown_in_html_blocks, tex_math_dollars, and native_divs.

Usage

1
render_html(path_in, ..., quiet = FALSE)

Arguments

path_in

path to a markdown file

...

extra options (e.g. lua filters) to be passed to pandoc

quiet

if TRUE, no output is produced. Default is FALSE, which reports the markdown build via pandoc

Value

a character containing the rendred HTML file

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
if (rmarkdown::pandoc_available("2.11")) {
# first example---markdown to HTML
tmp <- tempfile()
ex <- c("# Markdown", 
  "", 
  "::: challenge", 
  "", 
  "How do you write markdown divs?",
  "", 
  ":::"
)
writeLines(ex, tmp)
cat(sandpaper:::render_html(tmp))

# adding a lua filter

lua <- tempfile()
lu <- c("Str = function (elem)",
"  if elem.text == 'markdown' then",
"    return pandoc.Emph {pandoc.Str 'mowdrank'}",
"  end",
"end")
writeLines(lu, lua)
lf <- paste0("--lua-filter=", lua)
cat(sandpaper:::render_html(tmp, lf))
}

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