Templates are objects which are meant to capture the structure of an R Markdown document and facilitate the comparison between the template and new Rmd documents, usually to ensure the structure and/or content matches sufficiently.
Usage
rmd_template(
rmd,
keep_content = FALSE,
keep_labels = TRUE,
keep_headings = FALSE,
keep_yaml = FALSE,
...
)
Arguments
- rmd
R Markdown document in the form of an
rmd_ast
orrmd_tibble
.- keep_content
Should the template keep the document's content (markdown text and chunk code).
- keep_labels
Should the template keep the document's code chunk labels.
- keep_headings
Should the template keep the document's headings.
- keep_yaml
Should the template keep the document's yaml.
- ...
Unused, for extensibility.
Value
Returns an rmd_template
object, which is a derived tibble containing relevant structural
details of the document.
Examples
rmd = parse_rmd(system.file("examples/hw01.Rmd", package="parsermd"))
rmd_select(rmd, by_section(c("Exercise *", "Solution"))) %>%
rmd_template()
#> # A tibble: 9 × 4
#> sec_h3 sec_h4 type label
#> <chr> <chr> <chr> <chr>
#> 1 Exercise 1 Solution rmd_markdown NA
#> 2 Exercise 2 Solution rmd_markdown NA
#> 3 Exercise 2 Solution rmd_chunk plot-dino
#> 4 Exercise 2 Solution rmd_markdown NA
#> 5 Exercise 2 Solution rmd_chunk cor-dino
#> 6 Exercise 3 Solution rmd_markdown NA
#> 7 Exercise 3 Solution rmd_chunk plot-star
#> 8 Exercise 3 Solution rmd_markdown NA
#> 9 Exercise 3 Solution rmd_chunk cor-star