Escape Text for a Target Output Format
escape.RdEscapes special characters in a character vector so that the text can be safely inserted into Markdown, LaTeX, or HTML output.
Usage
escape(x, fmt = c("markdown", "tex", "html"))Details
This function is intended for escaping plain text before wrapping it in lightweight formatting helpers such as [bold()], [italic()], or [code()].
For Markdown, this function performs conservative escaping of characters that commonly have syntactic meaning, including emphasis markers, brackets, braces, list markers, pipes, and backslashes.
For LaTeX, this function escapes the standard special characters: `\`, ``, ``, `#`, `$`, `
For HTML, this function escapes: `&`, `<`, `>`, `"`, and `'`.
Markdown inline code spans are a special case. When formatting code, prefer [code()] rather than calling `escape(x, "markdown")` directly, because inline code delimiters need to be chosen according to the content.