html_esc: Escape Characters With Special HTML Meaning

View source: R/misc.R

html_escR Documentation

Escape Characters With Special HTML Meaning

Description

Arbitrary text may contain characters with special meaning in HTML, which may cause HTML display to be corrupted if they are included unescaped in a web page. This function escapes those special characters so they do not interfere with the HTML markup generated by e.g. to_html.

Usage

html_esc(x, what = getOption("fansi.html.esc", "<>&'\""))

Arguments

x

character vector

what

character(1) containing any combination of ASCII characters "<", ">", "&", "'", or "\"". These characters are special in HTML contexts and will be substituted by their HTML entity code. By default, all special characters are escaped, but in many cases "<>&" or even "<>" might be sufficient. @return x, but with the what characters replaced by their HTML entity codes.

Note

Non-ASCII strings are converted to and returned in UTF-8 encoding.

See Also

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

Examples

html_esc("day > night")
html_esc("<SPAN>hello world</SPAN>")

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