ansi_strwrap | R Documentation |
This function is similar to base::strwrap()
, but works on ANSI
styled strings, and leaves the styling intact.
ansi_strwrap(
x,
width = console_width(),
indent = 0,
exdent = 0,
simplify = TRUE
)
x |
ANSI string. |
width |
Width to wrap to. |
indent |
Indentation of the first line of each paragraph. |
exdent |
Indentation of the subsequent lines of each paragraph. |
simplify |
Whether to return all wrapped strings in a single
character vector, or wrap each element of |
If simplify
is FALSE
, then a list of character vectors,
each an ANSI string. Otherwise a single ANSI string vector.
Other ANSI string operations:
ansi_align()
,
ansi_columns()
,
ansi_nchar()
,
ansi_strsplit()
,
ansi_strtrim()
,
ansi_substring()
,
ansi_substr()
,
ansi_toupper()
,
ansi_trimws()
text <- cli:::lorem_ipsum()
# Highlight some words, that start with 's'
rexp <- gregexpr("\\b([sS][a-zA-Z]+)\\b", text)
regmatches(text, rexp) <- lapply(regmatches(text, rexp), col_red)
cat(text)
wrp <- ansi_strwrap(text, width = 40)
cat(wrp, sep = "\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.