Wrap long lines in Rmd files
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)
- the input Rmd file
- the expected line width
- an alternative to
fileto input the text lines
- the path to back up the original file (in case anything goes
NULL, it is ignored; by default it is constructed from
__before the base filename
fileis provided, it is overwritten; if
textis provided, a character vector is returned.
Currently it does not wrap blockquotes or lists (ordered or unordered). This feature may or may not be added in the future.
wrap_rmd(text = c("```", "1+1", "```", "- a list item", "> a quote", "", paste(rep("this is a normal paragraph", 5), collapse = "")))