Examples for 'cli::ansi_html'


Convert ANSI styled text to HTML

Aliases: ansi_html

Keywords:

### ** Examples

## Don't show: 
if (cli:::has_packages(c("htmltools", "withr"))) (if (getRversion() >= "3.4") withAutoprint else force)({ # examplesIf
## End(Don't show)
## Syntax highlight the source code of an R function with ANSI tags,
## and export it to a HTML file.
code <- withr::with_options(
  list(ansi.num_colors = 256),
  code_highlight(format(ansi_html))
)
hcode <- paste(ansi_html(code), collapse = "\n")
css <- paste(format(ansi_html_style()), collapse=  "\n")
page <- htmltools::tagList(
  htmltools::tags$head(htmltools::tags$style(css)),
  htmltools::tags$pre(htmltools::HTML(hcode))
)

if (interactive()) htmltools::html_print(page)
## Don't show: 
}) # examplesIf
> code <- withr::with_options(list(ansi.num_colors = 256), code_highlight(format(ansi_html)))
> hcode <- paste(ansi_html(code), collapse = "\n")
> css <- paste(format(ansi_html_style()), collapse = "\n")
> page <- htmltools::tagList(htmltools::tags$head(htmltools::tags$style(css)), 
+     htmltools::tags$pre(htmltools::HTML(hcode)))
> if (interactive()) htmltools::html_print(page)
## End(Don't show)

[Package cli version 3.6.3 Index]