Escaper instances suitable for strings to be included in HTML attribute values and
most elements' text contents. When possible, avoid manual escaping by using templating
systems and high-level APIs that provide autoescaping.
One Google-authored templating system available for external use is Closure Templates.
HTML escaping is particularly tricky: For example, some
elements' text contents must not be HTML escaped. As a result, it is impossible to escape an
HTML document correctly without domain-specific knowledge beyond what HtmlEscapers
provides. We strongly encourage the use of HTML templating systems.
| Modifier and Type | Field and Description |
|---|---|
| private static final Escaper |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Escaper | htmlEscaper()
Returns an |
| HTML_ESCAPER | back to summary |
|---|---|
| private static final Escaper HTML_ESCAPER | |
| HtmlEscapers | back to summary |
|---|---|
| private HtmlEscapers() | |
| htmlEscaper | back to summary |
|---|---|
| public static Escaper htmlEscaper() Returns an Note This escaper only performs minimal escaping to make content structurally
compatible with HTML. Specifically, it does not perform entity replacement (symbolic or
numeric), so it does not replace non-ASCII code points with character references. This escaper
escapes only the following five ASCII characters: | |