in_html: Frame HTML in a Web Page And Display

View source: R/tohtml.R

in_htmlR Documentation

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)

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.

Value

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

See Also

make_styles().

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

Examples

txt <- "\033[31;42mHello \033[7mWorld\033[m"
writeLines(txt)
html <- to_html(txt)
## Not run: 
in_html(html) # spawns a browser window

## End(Not run)
writeLines(readLines(in_html(html, display=FALSE)))
css <- "SPAN {text-decoration: underline;}"
writeLines(readLines(in_html(html, css=css, display=FALSE)))
## Not run: 
in_html(html, css)

## End(Not run)

fansi documentation built on Oct. 9, 2023, 1:07 a.m.