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.
Arguments
- file
The input Rmd file.
- width
The expected line width.
- text
A character vector of text lines, as an alternative to
file. Iftextis notNULL,fileis ignored.- backup
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 fromfileby adding__before the base filename.
Note
Currently it does not wrap blockquotes or lists (ordered or unordered). This feature may or may not be added in the future.
Examples
wrap_rmd(text = c("```", "1+1", "```", "- a list item", "> a quote", "",
paste(rep("this is a normal paragraph", 5), collapse = " ")))
#> [1] "```"
#> [2] "1+1"
#> [3] "```"
#> [4] "- a list item"
#> [5] "> a quote"
#> [6] ""
#> [7] "this is a normal paragraph this is a normal paragraph this is a normal"
#> [8] "paragraph this is a normal paragraph this is a normal paragraph"