Only the colors, background-colors, and basic styles (CSI SGR codes 1-9) are translated. Others are dropped silently.
sgr_to_html(x, warn = getOption("fansi.warn"),
term.cap = getOption("fansi.term.cap"))
a character vector or object that can be coerced to character.
TRUE (default) or FALSE, whether to warn when potentially
problematic Control Sequences are encountered. These could cause the
assumptions fansi
makes about how strings are rendered on your display
to be incorrect, for example by moving the cursor (see fansi).
character a vector of the capabilities of the terminal, can
be any combination "bright" (SGR codes 90-97, 100-107), "256" (SGR codes
starting with "38;5" or "48;5"), and "truecolor" (SGR codes starting with
"38;2" or "48;2"). Changing this parameter changes how fansi
interprets
escape sequences, so you should ensure that it matches your terminal
capabilities. See term_cap_test for details.
a character vector with all escape sequences removed and any basic ANSI CSI SGR escape sequences applied via SPAN html objects with inline css styles.
fansi for details on how Control Sequences are
interpreted, particularly if you are getting unexpected results,
set_knit_hooks()
for how to use ANSI CSI styled text with knitr and HTML
output.
# NOT RUN {
sgr_to_html("hello\033[31;42;1mworld\033[m")
# }
Run the code above in your browser using DataLab