html: Interpret input text as HTML-formatted text

View source: R/helpers.R

htmlR Documentation

Interpret input text as HTML-formatted text

Description

For certain pieces of text (like in column labels or table headings) we may want to express them as raw HTML. In fact, with HTML, anything goes so it can be much more than just text. The html() function will guard the input HTML against escaping, so, your HTML tags will come through as HTML when rendered... to HTML.

Usage

html(text, ...)

Arguments

text

HTML text

⁠scalar<character>⁠ // required

The text that is understood to be HTML text, which is to be preserved in the HTML output context.

...

Optional parameters for htmltools::HTML()

⁠<multiple expressions>⁠ // (optional)

The htmltools::HTML() function contains ... and anything provided here will be passed to that internal function call.

Value

A character object of class html. It's tagged as an HTML fragment that is not to be sanitized.

Examples

Use the exibble dataset to create a gt table. When adding a title through tab_header(), we'll use the html() helper to signify to gt that we're using HTML formatting.

exibble |>
  dplyr::select(currency, char) |>
  gt() |>
  tab_header(title = html("<em>HTML</em>"))
This image of a table was generated from the first code example in the `html()` help file.

Function ID

8-2

Function Introduced

v0.2.0.5 (March 31, 2020)

See Also

Other helper functions: adjust_luminance(), cell_borders(), cell_fill(), cell_text(), currency(), default_fonts(), escape_latex(), from_column(), google_font(), gt_latex_dependencies(), md(), nanoplot_options(), pct(), px(), random_id(), row_group(), stub(), system_fonts(), unit_conversion()


rstudio/gt documentation built on Nov. 2, 2024, 5:53 p.m.