fansi (version 0.4.0)

sgr_to_html: Convert ANSI CSI SGR Escape Sequence to HTML Equivalents

Description

Only the colors, background-colors, and basic styles (CSI SGR codes 1-9) are translated. Others are dropped silently.

Usage

sgr_to_html(x, warn = getOption("fansi.warn"),
  term.cap = getOption("fansi.term.cap"))

Arguments

x

a character vector or object that can be coerced to character.

warn

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).

term.cap

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.

Value

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.

See Also

fansi for details on how Control Sequences are interpreted, particularly if you are getting unexpected results.

Examples

Run this code
# NOT RUN {
sgr_to_html("hello\033[31;42;1mworld\033[m")
# }

Run the code above in your browser using DataCamp Workspace