text_wrap

0th

Percentile

Text Wrapping Utilities

Functions to break up character vector components to a specified width.

Keywords
internal
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 width we're allowed to wrap

hyphens

whether to allow hyphenation

unlist

logical(1L) if FALSE each element in x is returned as an element of a list, otherwise one character vector is returned

Details

  • text_wrap breaks each element to a specified width, where width can contain different values for each value in x

  • word_wrap wraps at whitespace, or crudely hyphenates if necessary; note that unlike text_wrap width must be scalar

  • word_cat is like word_wrap, except it outputs to screen

  • word_msg is like word_cat, except it ouputs to stderr

  • meta_word_cat is like word_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

Aliases
  • text_wrap
  • word_wrap
  • meta_word_cat
  • meta_word_msg
  • word_cat
  • word_msg
  • word_comment
Documentation reproduced from package unitizer, version 1.4.8, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.