Core wrapping functionality that preserves whitespace. Newline character "\n" is not supported
by core functionality stringi::stri_wrap(). This is usually solved beforehand by matrix_form().
If the width is smaller than any large word, these will be truncated after width characters. If
the split leaves trailing groups of empty spaces, they will be dropped.
A string if str is one element and if collapse = NULL. Otherwise, a list of elements
(if length(str) > 1) that can contain strings or vectors of characters (if collapse = NULL).
Arguments
str
(string, character, or list) string to be wrapped. If it is a vector or
a list, it will be looped as a list and returned with unlist(use.names = FALSE).
width
(numeric(1)) width, in characters, that the text should be wrapped to.
collapse
(string or NULL) collapse character used to separate segments of words that
have been split and should be pasted together. This is usually done internally with "\n" to update
the wrapping along with other internal values.
fontspec
(font_spec) a font_spec object specifying the font information to use for
calculating string widths and heights, as returned by font_spec().
Functions
wrap_txt(): Deprecated function. Please use wrap_string() instead.
Details
Word wrapping happens similarly to stringi::stri_wrap() with the following difference: individual
words which are longer than max_width are broken up in a way that fits with other word wrapping.