| ansi_align | R Documentation |
Align an ANSI colored string
ansi_align(
text,
width = console_width(),
align = c("left", "center", "right"),
type = "width"
)
text |
The character vector to align. |
width |
Width of the field to align in. |
align |
Whether to align |
type |
Passed on to |
str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, width = 30)
boxx(astr)
#> ┌────────────────────────────────────┐ #> │ │ #> │ This is red │ #> │ This is bold │ #> │ │ #> └────────────────────────────────────┘
str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, align = "center", width = 30)
boxx(astr)
#> ┌────────────────────────────────────┐ #> │ │ #> │ This is red │ #> │ This is bold │ #> │ │ #> └────────────────────────────────────┘
str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, align = "right", width = 30)
boxx(astr)
#> ┌────────────────────────────────────┐ #> │ │ #> │ This is red │ #> │ This is bold │ #> │ │ #> └────────────────────────────────────┘
The aligned character vector.
Other ANSI string operations:
ansi_columns(),
ansi_nchar(),
ansi_strsplit(),
ansi_strtrim(),
ansi_strwrap(),
ansi_substr(),
ansi_substring(),
ansi_toupper(),
ansi_trimws()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.