Wrap a string to within a maximum width
Arguments
- str
character(1). String to be wrapped
- max_width
numeric(1). Maximum width, in characters, that the text should be wrapped at.
- hard
logical(1). Should hard wrapping (embedding newlines in the incoming strings) or soft (breaking wrapped strings into vectors of length >1) be used. Defaults to
FALSE
(i.e. soft wrapping).- txt
character. A vector of strings that should be (independently) text-wrapped.
Value
A string (wrap_string
or character vector (wrap_txt
) containing
the hard or soft word-wrapped content.
Details
Word wrapping happens as with base::strwrap
with the following exception: individual words which are longer
than max_width
are broken up in a way that fits with the rest of the
word wrapping.