Skip to contents

This function takes a path to an R Markdown (.Rmd) file or a string vector of text from an Rmd file, cleans it by replacing specified patterns, and then splits it into sections and blocks. The result makes it easy to refer to each section/block with the plan functions of the package.

Usage

split_sections(
  x,
  sec_lv = 3,
  replacements_pat = NULL,
  split_args = NULL,
  clauses_sep = ".:;!?"
)

Arguments

x

A character vector containing the path to an Rmd file or the actual text from an Rmd file.

sec_lv

An integer specifying the maximum heading size (number) of "#" to be considered. Sub-sections lower than that won't be split.

replacements_pat

A named vector where names are patterns to match in the document's text and values are the replacements for those patterns. Passed to the pattern argument of str_replace_all. Defaults to no substitution.

split_args

A list of 'splits' to separate the sections and blocks. See the source code of morphdown:::get_split_args() for the default splits.

clauses_sep

A string with which characters to consider when splitting the clauses of a text expression. Defaults to ".:;!?".

Value

A named list of character vectors. Each vector is a section named s*. Each section has blocks named b*. Use those names to refer to each in the plan functions.