| fmt | R Documentation |
Formats text with specified color, styles, and background using ANSI escape codes or HTML, with support for plain text output.
fmt(
x,
col = NULL,
bold = FALSE,
italic = FALSE,
underline = FALSE,
thin = FALSE,
muted = FALSE,
bg = NULL,
pad = 0L,
output_type = c("ansi", "html", "plain")
)
x |
Character: Text to format. |
col |
Character: Color (hex code, named color, or NULL for no color). |
bold |
Logical: If TRUE, make text bold. |
italic |
Logical: If TRUE, make text italic. |
underline |
Logical: If TRUE, underline text. |
thin |
Logical: If TRUE, make text thin/light. |
muted |
Logical: If TRUE, make text muted/dimmed. |
bg |
Character: Background color (hex code, named color, or NULL). |
pad |
Integer: Number of spaces to pad before text. |
output_type |
Character: Output type ("ansi", "html", "plain"). |
This function combines multiple formatting options into a single call, making it more efficient than nested function calls. It generates optimized ANSI escape sequences and clean HTML output.
Character: Formatted text with specified styling.
EDG
# Simple color
fmt("Hello", col = "red")
# Bold red text
fmt("Error", col = "red", bold = TRUE)
# Multiple styles
fmt("Warning", col = "yellow", bold = TRUE, italic = TRUE)
# With background
fmt("Highlight", col = "white", bg = "blue", bold = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.