This function wraps long paragraphs in an R Markdown file. Other elements are not wrapped: the YAML preamble, fenced code blocks, section headers and indented elements. The main reason for wrapping long lines is to make it easier to review differences in version control.
wrap_rmd(file, width = 80, text = NULL, backup)
If file
is provided, it is overwritten; if text
is
provided, a character vector is returned.
The input Rmd file.
The expected line width.
A character vector of text lines, as an alternative to file
. If
text
is not NULL
, file
is ignored.
Path to back up the original file in case anything goes
wrong. If set to NULL
, no backup is made. The default value is constructed
from file
by adding __
before the base filename.
wrap_rmd(text = c("```", "1+1", "```", "- a list item", "> a quote", "",
paste(rep("this is a normal paragraph", 5), collapse = " ")))
Run the code above in your browser using DataLab