Skip to contents

This function compares the provided Rmd against a template and reports on discrepancies (e.g. missing or unmodified components).

Usage

rmd_check_template(rmd, template, ...)

Arguments

rmd

The rmd to be check, can be an rmd_ast, rmd_tibble, or text that can be handled by parse_rmd.

template

rmd_template object from rmd_template().

...

Unused, for extensibility.

Value

Invisibly returns TRUE if the rmd matches the template, FALSE otherwise.

Examples

tmpl = parse_rmd(system.file("examples/hw01.Rmd", package = "parsermd")) %>%
  rmd_select(by_section(c("Exercise *", "Solution"))) %>%
  rmd_template(keep_content = TRUE)

rmd_check_template(
  system.file("examples/hw01-student.Rmd", package = "parsermd"),
  tmpl
)
#>  The following required elements were missing in the document:
#>   • Section "Exercise 3" > "Solution" is missing required "markdown text".
#>   • Section "Exercise 3" > "Solution" is missing required "markdown text".
#> 
#>  The following document elements were unmodified from the template:
#>   • Section "Exercise 2" > "Solution" has a "code chunk" named "plot-dino"
#>     which has not been modified.
#>   • Section "Exercise 2" > "Solution" has "markdown text" which has not been
#>     modified.
#>   • Section "Exercise 2" > "Solution" has a "code chunk" named "cor-dino"
#>     which has not been modified.