///|
/// The `v_htmlescape` table, including slash escaping.
///
/// Replaces `"`, `&`, `'`, `/`, `<`, and `>` with `"`, `&`, `'`,
/// `/`, `<`, and `>` respectively. Other bytes/code units are preserved.
/// Existing entities are escaped again; this operation is not idempotent.
/// The immutable table is allocated once and may be shared across calls.
pub let html : Escaper = preset(
[
(b'"', """),
(b'&', "&"),
(b'\'', "'"),
(b'/', "/"),
(b'<', "<"),
(b'>', ">"),
],
Html,
)
///|
/// The `v_html5escape` table, which preserves `/`.
///
/// Replaces `"`, `&`, `'`, `<`, and `>` with the same entities as `html`.
/// All other input is preserved and emitted entities are never rescanned.
/// This is an immutable preset, not an HTML parser or sanitizer.
pub let html5 : Escaper = preset(
[
(b'"', """),
(b'&', "&"),
(b'\'', "'"),
(b'<', "<"),
(b'>', ">"),
],
Html5,
)
///|
/// The `v_jsonescape` JSON string-content table, without surrounding quotes.
///
/// Replaces U+0000..U+001F, `"`, and `\`. Backspace, tab, newline, form feed,
/// and carriage return use `\b`, `\t`, `\n`, `\f`, and `\r`; other controls use
/// lowercase four-digit `\u00xx` escapes. Slash, DEL, non-ASCII text, U+2028,
/// and U+2029 are preserved. Byte output does not validate UTF-8, so arbitrary
/// byte input need not produce valid JSON text. The table is immutable.
pub let json : Escaper = preset(
[
(0x00, "\\u0000"),
(0x01, "\\u0001"),
(0x02, "\\u0002"),
(0x03, "\\u0003"),
(0x04, "\\u0004"),
(0x05, "\\u0005"),
(0x06, "\\u0006"),
(0x07, "\\u0007"),
(0x08, "\\b"),
(0x09, "\\t"),
(0x0a, "\\n"),
(0x0b, "\\u000b"),
(0x0c, "\\f"),
(0x0d, "\\r"),
(0x0e, "\\u000e"),
(0x0f, "\\u000f"),
(0x10, "\\u0010"),
(0x11, "\\u0011"),
(0x12, "\\u0012"),
(0x13, "\\u0013"),
(0x14, "\\u0014"),
(0x15, "\\u0015"),
(0x16, "\\u0016"),
(0x17, "\\u0017"),
(0x18, "\\u0018"),
(0x19, "\\u0019"),
(0x1a, "\\u001a"),
(0x1b, "\\u001b"),
(0x1c, "\\u001c"),
(0x1d, "\\u001d"),
(0x1e, "\\u001e"),
(0x1f, "\\u001f"),
(b'"', "\\\""),
(b'\\', "\\\\"),
],
Json,
)
///|
/// The exact twelve-entry `v_latexescape` text table.
///
/// Prefixes `#`, `$`, `%`, `&`, `_`, `{`, and `}` with a backslash. Replaces
/// `<`, `>`, `\`, `^`, and `~` with `\textless{}`, `\textgreater{}`,
/// `\textbackslash{}`, `\textasciicircum{}`, and `\textasciitilde{}` respectively.
/// Other input is preserved; this does not parse LaTeX or choose math-mode
/// escaping. Replacement macros are emitted once. The table is immutable.
pub let latex : Escaper = preset(
[
(b'#', "\\#"),
(b'$', "\\$"),
(b'%', "\\%"),
(b'&', "\\&"),
(b'<', "\\textless{}"),
(b'>', "\\textgreater{}"),
(b'\\', "\\textbackslash{}"),
(b'^', "\\textasciicircum{}"),
(b'_', "\\_"),
(b'{', "\\{"),
(b'}', "\\}"),
(b'~', "\\textasciitilde{}"),
],
Latex,
)