This function splits long lines at a given number of characters, keeping words intact. It's basically a wrapper around strwrap().

split_long_lines(
  x,
  length = 60,
  splitString = rock::opts$get("utteranceMarker")
)

Arguments

x

The string (e.g. a source)

length

The maximum length

splitString

The character to use to split lines.

Value

A character vector.

Examples

cat(
  rock::split_long_lines(
    paste0(
      "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
      "Vestibulum et dictum urna. Donec neque nunc, lacinia vitae ",
      "varius vitae, pretium quis nibh. Aliquam pulvinar, lacus ",
      "sed varius vulputate, justo nibh blandit quam, ",
      "nec sollicitudin velit augue eget erat."
    )
  )
);
#> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
#> Vestibulum et dictum urna. Donec neque nunc, lacinia vitae
#> varius vitae, pretium quis nibh. Aliquam pulvinar, lacus
#> sed varius vulputate, justo nibh blandit quam, nec
#> sollicitudin velit augue eget erat.