text_wrap {unitizer} | R Documentation |
Text Wrapping Utilities
Description
Functions to break up character vector components to a specified width.
Usage
text_wrap(x, width)
word_wrap(
x,
width = getOption("width"),
tolerance = 8L,
hyphens = TRUE,
unlist = TRUE,
collapse = NULL
)
meta_word_cat(
...,
sep = "\n",
width = getOption("width"),
tolerance = 8L,
file = stdout(),
trail.nl = TRUE
)
meta_word_msg(
...,
sep = "\n",
width = getOption("width"),
tolerance = 8L,
trail.nl = TRUE
)
word_cat(
...,
sep = " ",
width = getOption("width"),
tolerance = 8L,
file = stdout()
)
word_msg(...)
word_comment(
x,
width = getOption("width"),
tolerance = 8L,
hyphens = TRUE,
unlist = TRUE,
color = crayon::has_color()
)
Arguments
x |
character vector |
width |
what width to wrap at |
tolerance |
how much earlier than |
hyphens |
whether to allow hyphenation |
unlist |
logical(1L) if FALSE each element in |
Details
-
text_wrap
breaks each element to a specifiedwidth
, wherewidth
can contain different values for each value inx
-
word_wrap
wraps at whitespace, or crudely hyphenates if necessary; note that unliketext_wrap
width
must be scalar -
word_cat
is likeword_wrap
, except it outputs to screen -
word_msg
is likeword_cat
, except it ouputs to stderr -
meta_word_cat
is likeword_cat
, except it wraps output in formatting to highlight this is not normal output
Newlines are replaced by empty strings in the output so that each character vector in the output represents a line of screen output.
Value
a list with, for each item in x
, a character vector
of the item wrapped to length width
if unlist
is a parameter, then a character vector, or
if not or if unlist
is FALSE, a list with each element from x
corresponding to an element from the list