Learn R Programming

fansi (version 1.0.6)

in_html: Frame HTML in a Web Page And Display

Description

Helper function that assembles user provided HTML and CSS into a temporary text file, and by default displays it in the browser. Intended for use in examples.

Usage

in_html(x, css = character(), pre = TRUE, display = TRUE, clean = display)

Value

character(1L) the file location of the page, invisibly, but keep in mind it will have been deleted if clean=TRUE.

Arguments

x

character vector of html encoded strings.

css

character vector of css styles.

pre

TRUE (default) or FALSE, whether to wrap x in PRE tags.

display

TRUE or FALSE, whether to display the resulting page in a browser window. If TRUE, will sleep for one second before returning, and will delete the temporary file used to store the HTML.

clean

TRUE or FALSE, if TRUE and display == TRUE, will delete the temporary file used for the web page, otherwise will leave it.

See Also

make_styles().

Other HTML functions: html_esc(), make_styles(), to_html()

Examples

Run this code
txt <- "\033[31;42mHello \033[7mWorld\033[m"
writeLines(txt)
html <- to_html(txt)
if (FALSE) {
in_html(html) # spawns a browser window
}
writeLines(readLines(in_html(html, display=FALSE)))
css <- "SPAN {text-decoration: underline;}"
writeLines(readLines(in_html(html, css=css, display=FALSE)))
if (FALSE) {
in_html(html, css)
}

Run the code above in your browser using DataLab