html_code_block: Format Character Vector for Display as Code in HTML

View source: R/misc.R

html_code_blockR Documentation

Format Character Vector for Display as Code in HTML

Description

This simulates what rmarkdown / knitr do to the output of an R markdown chunk, at least as of rmarkdown 1.10. It is useful when we override the knitr output hooks so that we can have a result that still looks as if it was run by knitr.

Usage

html_code_block(x, class = "fansi-output")

Arguments

x

character vector

class

character vectors of classes to apply to the PRE HTML tags. It is the users responsibility to ensure the classes are valid CSS class names.

Value

character(1L) x, with <PRE> and <CODE> HTML tags applied and collapsed into one line with newlines as the line separator.

Examples

html_code_block(c("hello world"))
html_code_block(c("hello world"), class="pretty")

fansi documentation built on May 29, 2024, 4:03 a.m.